I want to run a query between my two tables and returns the results to me the lines that are not present in my table 2
Asked
Active
Viewed 105 times
3 Answers
2
select * from table1
left join table2
on table1.id=table2.id
where table2.id is null

Shakti Singh
- 84,385
- 21
- 134
- 153
-
sorry, the same answer at the same time. Do you want me to delete mine? – Marco Apr 12 '11 at 08:05
-
@Macro: What for sorry? No problem. This is natural on SO – Shakti Singh Apr 12 '11 at 08:07
0
Should be something like this:
SELECT * FROM table2 WHERE table1_id NOT IN (SELECT id FROM table1)

Richard Tuin
- 4,484
- 2
- 19
- 18