求mysql语句
各位我有一个主表id:
1
2
3
4
5
从表(主表外键Id)
1
2
3
我现在要查处id=1和第四条和第五条,怎么查询
——解决方案——————–
- SQL code
select * from 主表 where id not in (select 1 from 从表)
------解决方案--------------------
- SQL code
select a.* from 主表 a left join 从表 b on a.id=b.id where b.id is null
------解决方案--------------------
select a.* from 主表 a left join 从表 b on a.id=b.id where b.id is null
union
select * from 主表 where id=1
------解决方案--------------------
查找1 4 5?
这有什么规则吗欢迎大家阅读《求mysql语句解决方法》,跪求各位点评,by 搞代码