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 > table joining

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-29-04, 06:31
sez sez is offline
Registered User
 
Join Date: Mar 2004
Posts: 1
table joining

Hello

please forgive me if this is really easy, but I am new to the world of mysql and am on a fairly tight timeframe.
I am trying to find all the values in one table which don't appear in another.
ie, I have a database x, which has a table, y, which lists shots in it.
I have another database a, which has another table, b, which also lists all the shots. I need to know which shots in x.y don't appear in a.b

simple, I am sure, but it's driving me nuts.

thanks!
sez
Reply With Quote
  #2 (permalink)  
Old 03-29-04, 06:57
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,525
PHP Code:
select shots
  from x
.as t1
left outer
  join a
.as t2
    on t1
.shots t2.shots
 where t2
.shots is null 
assuming the two databases are accessible by the same mysql server
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 03-29-04, 12:56
guelphdad guelphdad is offline
Registered User
 
Join Date: Mar 2004
Posts: 440
You might have to use select t1.shots instead of select shots
right at the beginning of Rudy's solution. I tried his solution since I hadn't done selects from multiple dbs before and got an ambiguous field error until I changed to t1.shots.
Reply With Quote
  #4 (permalink)  
Old 03-29-04, 13:17
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,525
DOH!

thanks, guelphdad
__________________
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