,我需要选择&集团Id
& Pid
时至少各1个Pid
在Id
有IsExists=1
SQL选择及集团,如果存在至少一个
Id Pid Opt IsExists
27 2 107 1
27 2 108 0
27 5 96 1
51 9 17 1
51 9 18 0
51 10 112 0
758 25 96 0
758 97 954 1
758 194 2902 1
758 194 2903 1
结果应该是:
Id IsExists
27 1
- 在
[id=27 | pid=2]
的结果&的[id=27 | pid=5]
至少有1个与isExists=1
这可能吗?
您正在使用哪个RDBMS更多? –
我正在使用SQL Server – Eyal
一个ID只能有一个与之关联的PID吗?所以对于ID = 27 PID = 2而没有别的。 – objectNotFound