开发者

how to do a SQL Join that returns the rows that are not present in my table 2

开发者 https://www.devze.com 2023-02-24 04:50 出处:网络
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 开发者_如何学编程2select * from table1

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


select * from table1 
         left join table2 
         on table1.id=table2.id 
         where table2.id is null


Look at this post.
I copied the code:

select * from A left join B on A.x=B.y where B.y is null;


Should be something like this:

SELECT * FROM table2 WHERE table1_id NOT IN (SELECT id FROM table1) 
0

精彩评论

暂无评论...
验证码 换一张
取 消