【发布时间】:2020-08-03 01:14:14
【问题描述】:
我想选择拥有type=a和product=1的客户
customer type product
A a 1
A b 1
A c 2
B b 2
B b 1
C c 1
C c 1
因此我想要的结果如下
customer type product
A a 1
A b 1
A c 2
我想在下面的示例中添加选择器product = 1。
SELECT t1.customer, t1.type ,t1.product
FROM yourTable t1
WHERE EXISTS (SELECT 1 FROM yourTable t2 WHERE t2.customer = t1.customer AND t2.type = 'a');
因为我是入门级的。如果有人有意见,请告诉我。 谢谢
【问题讨论】:
-
我不明白。附加条件不是很明显吗?您对这个问题有什么困惑?