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 > comparing two lists

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-17-06, 04:43
fishkake fishkake is offline
Registered User
 
Join Date: Dec 2005
Posts: 28
comparing two lists

Lets say I have 3 "lists" (by which I mean columns resulting from a select statement):

List 1:
a
b
c
d

List 2:
a
b
c
d
e
f

Can I return:

List 3
e
f

(i.e. all the records which are in list 2 but not in list 1). It seems strange that I cannot do this.
Reply With Quote
  #2 (permalink)  
Old 03-17-06, 06:14
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
yep, with a LEFT OUT JOIN
Code:
select x
  from ( select  statement ) as list2
left outer
  join  ( select  statement ) as list1
    on list1.x = list2.x
 where list1.x is null
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 03-17-06, 09:05
Pat Phelan Pat Phelan is offline
Resident Curmudgeon
 
Join Date: Feb 2004
Location: In front of the computer
Posts: 12,609
As R937 said, Yes.

-PatP
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