ylleigh12 ylleigh12 - 3 months ago 7
SQL Question

Selecting from one table that does not exist on another table

How can I select user 3, 4, 5 from table1 based on the condition that their number is NOT 100 on table2?

**table1 table2**
id name id number
1 user1 1 100
2 user2 2 100
3 user3 3 200
4 user4 4 200
5 user5 1 300
2 300

Answer
select name,id from table1 where id not in 
(select id from table2 where number=100)