SQL select query problem

Hello EE,

Let'say i have 2 tables.

First table has:   ID, Description
Second has ID, (same id that table1)

in first table i have values:    1,2,3,4,5

how can I do a SELECT that if there is nothing in table 2  it returns  1,2,3,4,5  if lets say there is 1 and 3 it will return 1,2,4,5

lets say in table 2 there is 4,5  it would return 1,2,3

can y u help ?
LVL 1
PhilippeRenaudAsked:
Who is Participating?
 
knightEknightCommented:
select *
from Table1
where ID not in (select distinct ID from Table2)
0
 
Ephraim WangoyaCommented:

select ID, Description
from table1
left join table2 on table2.id = table1.id
where table2.id is null
0
 
PhilippeRenaudAuthor Commented:
ahh...thanks.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.