• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

Regarding Join

 
Ranch Hand
Posts: 268
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I actually have three rows in addissue table but when i run this query i am getting nine. Here expiry is a view.

So please any body correct me.
Thanks and regards.
 
Marshal
Posts: 80751
486
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Not sure, but you are not joining anything. I think it would work better with a WHERE clause, otherwise you get the Cartesian Product of the lines in the table and the lines (presumably also 3; 3*3=9) in the view.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Adeeb,

If you have:

select a.added,a.curr_date,e.days from addissue a,expiry e;

you need to relate the tables. For example if the relationship is that you want the expiry days for the given added issue, there should be a column that identifies which issue it is in AddIssue, and then a column that joins with it in Expiry.

e.g. select a.added, a.curr_date, e.days from addissue a, expiry e
where a.id = e.addissue

Here is more information on joins: http://www.w3schools.com/Sql/sql_join.asp
 
Campbell Ritchie
Marshal
Posts: 80751
486
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That is exactly the sort of thing I meant, V. M. Koffman, and we hope to make you feel welcome here at JavaRanch
reply
    Bookmark Topic Watch Topic
  • New Topic