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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Select what is in one table and not in the other

Status
Not open for further replies.

andnos

Technical User
Nov 21, 2005
48
US
Hello,

I have a dilema, I have two tables, the primary ID from the first is a foreign ID in the second. How can I structure a query to select only the records from the first table ONLY IF the primary ID of this table is not listed in the secondary table as a foreign key.

thanks for any help

Andy
 
Sorry for leaving out that critical info:

MySQL 4.1.19
 
You rock Cory!!!! works great..
I need to read up more on my sql skills..
 
Thanks for the tip, I've tried mysql.com, but it takes like an hour and 10 pages before I can exactly what I need.

Can you help me with this, since you're on a roll:

In table1, I have a foreign key from table2, in table two, the key has listed titles, is it possible to write one query where I select the foreign key from table 1 (among other things), and in the same query it pulls the titles that is refereced in table2? or do I have to do two queries?

Again, thanks for the help...
 
Killer... works like magic.. and I need to go to barnes and noble and buy two books on MySQL.

thanks for the help Cory
 
I always buy two books on a subject that I'm fuzzy in.

1) is the XXX For Dummies to get the big picture of the subject, and 2) The Advanced/Professional Guide to XXX, to get the details once I know what can be accomplished
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top