...

View Full Version : display unique items?



jedimastermopar
02-16-2007, 04:11 AM
Hey guys n gals, I have two tables,

table1
idnum, detail1, detail2, detail3
1,bla,bla,bla
2,bla,bla,bla
3,bla,bla,bla
6,bla,bla,bla
7,bla,bla,bla
9,bla,bla,bla
10,bla,bla,bla


table2
idnum
1
2
3
4
5
6
7
8
9
10
11
12

table2 has more idnum values than in table1, and I need to make a list of all the values not found in table 2.

In the above table example I would like the query to display
4,5,8,11,12

Fumigator
02-16-2007, 06:16 AM
You can use a subquery if your version of MySQL is >= 4.1:



SELECT table2.idnum
FROM table2
WHERE not exists (SELECT * FROM table1 WHERE table1.idnum = table2.idnum)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum