Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

query help

Status
Not open for further replies.

NSmoller

Technical User
Jan 26, 2006
9
US
What is the difference between these?

SELECT LocalList.MD, Locallist.patient, locallist.SSN, locallist.drug, locallist.Lastfill
FROM Locallist, Duplicates
WHERE Locallist.Patient=Duplicates.Patient
ORDER BY locallist.MD, locallist.LastFill;

SELECT LocalList.MD, Locallist.patient, locallist.SSN, locallist.drug, locallist.Lastfill
FROM Locallist
WHERE Locallist.Patient IN (Select patient from duplicates)
ORDER BY locallist.MD, locallist.LastFill;


 
the first creates a cartesan product of the two tables. check out this link to understand exactly what that means.

The second uses a subquery (a query within another query).

Is there something specific that you wanted to know about them?

Leslie

Anything worth doing is a lot more difficult than it's worth - Unknown Induhvidual

Essential reading for anyone working with databases: The Fundamentals of Relational Database Design
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top