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!

Selecting All rows from one table that is not in the other

Status
Not open for further replies.

SomeSwede

Programmer
Oct 15, 2004
5
EU
It shouldn't be hard to do, I hope.

What I want to do is this:

select table1.id from table1,table2 where table1.id != table2.id .... I wish it was possible to write like that... but it doesn't I guess I can figure out the reason but anyway how should I do it? PLEAse help... example:

table1 table2
id 1 id2
id 2
id 3

select table1.id from table1,table2 where <what to write here?>

result:
id 1
id 3
 
Something like:

Code:
SELECT table1.id
  FROM table1 LEFT JOIN table2
    ON table1.id = table2.id
 WHERE table2.id IS NULL

Might work.

*cLFlaVA
----------------------------
Lois: "Peter, you're drunk!"
Peter: "I'm not drunk, I'm just exhausted from stayin' up all night drinking!
 
IT WORKS!!!! thank you thank you thank you thank you thank you thank you!

You've said me a lot of suffering and pain, and work.

You're now my hero.

 
Why thank you :)

*cLFlaVA
----------------------------
Lois: "Peter, you're drunk!"
Peter: "I'm not drunk, I'm just exhausted from stayin' up all night drinking!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top