【发布时间】:2019-12-05 15:40:09
【问题描述】:
我在这两个mysql表中有以下记录。
表-A
Question_No
1
2
3
4
5
表-B
Roll_No Question_No Ans_Option
1001 1 NULL
1001 2 D
1001 3 NULL
1002 1 C
1002 2 NULL
这里“NULL”这个词被显式插入到 column 中,没有什么可混淆的。
如何通过mysql查询显示如下结果?
Questions not attempted by roll no 1001 are : 1, 3, 4, 5
Questions not attempted by roll no 1002 are : 2, 3, 4, 5
我尝试使用以下代码但无法正常工作
select distinct a.* from table_A a NATURAL LEFT JOIN table_B b where
b.Question_No IS NULL and b.Roll_No=1001;// where I am wrong here ? I have
not set any column as primary key , should I set?
非常感谢提前
【问题讨论】:
标签: mysql sql join where-clause