2019-02-25
阅读量:
719
SQL查询问题
问题描述:
表A 表B
user_id name id user_id sorce
1 张三 1 1 78
2 李四 2 2
3 王五 3 5 80
想要查询表A中 没有分数或者表B中没有分数记录的,sql如何写?
select A.user_idid A.name FROM A LEFI JOIN B
ON A.user_id=B.user_id WHERE B.sorce='';
这个SQL不知道对不对?
1.表A中的user_id=3的王五,但王五的记录在B表中没有,我用左链接查询出来
2.sorce =''解决分数为空 查询出来
解决方法:
SELECT * FROM product.a left join product.b on aid=aid2 where b.aid2 is null or sc is null;
先用表连接把两个表按照规定的id链接在一起,aid对应是a表里的userid,aid2对应是b表的userid






评论(0)


暂无数据
推荐帖子
0条评论
0条评论
0条评论