oracle left join关联逻辑删除的数据
2020-08-07 本文已影响0人
一步一台阶
假设A表里含有id,del_flag字段,B表中含有id,a_id,del_flag字段
查询A表,同时关联查询B表中对应的数据,使用:
select * from A a left join B b on a.id=b.a_id where a.del_flag='0' and b.del_flag is null or b.del_flag='0'
假设A表里含有id,del_flag字段,B表中含有id,a_id,del_flag字段
查询A表,同时关联查询B表中对应的数据,使用:
select * from A a left join B b on a.id=b.a_id where a.del_flag='0' and b.del_flag is null or b.del_flag='0'