If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Will a JOIN get me there?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-11-06, 09:44
yebot yebot is offline
Registered User
 
Join Date: Aug 2005
Posts: 4
Will a JOIN get me there?

The situation:

I have two tables. First table has 3,000 - 4,000 records [userID, firstname, lastname, dateJoined, etc...]. Second table has about 100 records [userID, status, date, etc ...]. The database is MySQL v4.0.27 and I'm talking to it with phpMyAdmin 2.6.4-pl2.

What I want to accomplish:

I want to return all records in the FirstTable where the userID does not exist as a userID in the SecondTable. This sounds simple to me but I just haven't been able to get it to work.

Any advice from the fine minds at dbforums.com would be greatly appreciated.
Reply With Quote
  #2 (permalink)  
Old 07-11-06, 14:26
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
yes, a join will get you there

specifically, a LEFT OUTER JOIN where FirstTable is the left table and SecondTable is the right table, with a WHERE clause to check IS NULL in the right table's join condition

there's an example of this here -- http://dev.mysql.com/doc/refman/4.1/en/join.html
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On