Heim > Fragen und Antworten > Hauptteil
Implementierung: Datensätze in a abfragen, die nicht mit b in Zusammenhang stehen
1、select id from a left join b on a.id = b.aid where b.id is null and status = 1
2、select id from a where id not in (select aid from b) and status = 1
Welches ist besser oder wenn es einen anderen Weg gibt, hinterlassen Sie bitte eine Antwort
高洛峰2017-06-06 09:54:24
not exists正解
select id from a where not exists (select 1 from b where a.id=b.aid) and status = 1