## name
id name class_id
1 xiaoming 1null liming 23 xiaozhang 3## class
id class_name
1 class_1
2 class_2
null class_3
insertintotable name values(1,'xiaoming',1);insertintotable name values(null,'liming',2);insertintotable name values(3,'xiaozhang',3);insertintotable`class`values(1,'class_1');insertintotable`class`values(2,'class_2');insertintotable`class`values(null,'class_3');
in
select id,name,class_id from tmp.name where id in(select id from tmp.`class`)
结果:
1 xiaoming 1
select id,name,class_id from tmp.name wherenot id in(select id from tmp.`class`)
结果:
无值
exists
select id,name,class_id from tmp.name whereexists(select id from tmp.`class`where name.id =`class`.id)
结果:
1 xiaoming 1
select id,name,class_id from tmp.name wherenotexists(select id from tmp.`class`where name.id =`class`.id)
结果:
null liming 23 xiaozhang 3