a表1,2,3.
b表2,3,4
全連接結(jié)果:
1,null
2,2
3,3
null,4
where 選中帶有null的值
1,null
null,4
b表2,3,4
全連接結(jié)果:
1,null
2,2
3,3
null,4
where 選中帶有null的值
1,null
null,4
2019-01-24
表a,id為1,2,3
表b,id為2,3,4
想找出不和b表id相等的數(shù)據(jù)。
(notin方法)
select * from a
where a.id not in (
select id from b
)
(leftjoin方法)
(1)
select * from a
left join b
on a.id=b.id
查出1,null ;2,2;3,3三條數(shù)據(jù)
上面sql加上where限制,where b.id=null, 就只剩下一條id=1的數(shù)據(jù)
表b,id為2,3,4
想找出不和b表id相等的數(shù)據(jù)。
(notin方法)
select * from a
where a.id not in (
select id from b
)
(leftjoin方法)
(1)
select * from a
left join b
on a.id=b.id
查出1,null ;2,2;3,3三條數(shù)據(jù)
上面sql加上where限制,where b.id=null, 就只剩下一條id=1的數(shù)據(jù)
2019-01-24
已采納回答 / _好久不見_2
哈哈哈,你問的問題就是答案。他的作用就是獲取所有數(shù)據(jù)在一列上面,然后遍歷。假如你想要所有數(shù)據(jù),然后不在同一列,你取出來 就要進行數(shù)據(jù)合并 然后遍歷 或者兩列分開遍歷。
2019-01-02
最新回答 / 180416
left join 加上的: where b.字段名 is null ; 或者 right join 加: where a.字段名 is null去掉相同的部分就行
2018-12-04
最新回答 / 慕雪6618084
select user_id,timestr,kills,(slelect count(*) from user_kills b where b-user_id=auser_id and a.lills <= b.killls)? ? ad cnt from use_kills a group by user_id = d.id here
2018-11-07
UPDATE `取經(jīng)四人組`
SET ending='齊天大圣' WHERE `取經(jīng)四人組`.user_name in
(SELECT * FROM(SELECT `取經(jīng)四人組`.user_name
FROM `取經(jīng)四人組` INNER JOIN `孫悟空的朋友` ON `取經(jīng)四人組`.user_name = `孫悟空的朋友`.user_name )as temp)
SET ending='齊天大圣' WHERE `取經(jīng)四人組`.user_name in
(SELECT * FROM(SELECT `取經(jīng)四人組`.user_name
FROM `取經(jīng)四人組` INNER JOIN `孫悟空的朋友` ON `取經(jīng)四人組`.user_name = `孫悟空的朋友`.user_name )as temp)
2018-10-18