求mysql语句
各位我有一个主表id:
1
2
3
4
5
从表(主表外键Id)
1
2
3
我现在要查处id=1和第四条和第五条,怎么查询
[解决办法]
select *from 主表 where id not in (select 1 from 从表)
[解决办法]
select a.*from 主表 a left join 从表 b on a.id=b.idwhere 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?
这有什么规则吗