【发布时间】:2020-03-30 10:40:49
【问题描述】:
我需要从同一个表中不存在的表中选择寄存器。我的意思是如果我有这张桌子:
ID VALUE1 VALUE2 VALUE3
1 1 1 1
2 2 2 1
3 3 4 1
4 1 5 1
5 2 2 2
6 3 4 2
7 1 8 2
8 2 2 2
查询的结果应该是
ID VALUE1 VALUE2 VALUE3
1 1 1 1
4 1 5 1
因为 value1 和 value2 的其余值相同,但 value3 不同。我的意思是表的第 2 行与第 5 行相同。
我尝试做类似但不起作用的事情:
select t1.value1, t1.value2 from table1 t1 where value3=1
and not exist
(select t2.value1, t2.value2 from table2 t2
where t1.value1=t2.value1 and t1.value2=t2.value2 and value3=2)
谢谢你的建议,对不起我的英语
【问题讨论】: