我有一个这样的表:
RS Value Measure Feature
1 x1 a 5k
1 x2 b 5k
1 x3 b 10k
1 x4 c 10k
2 y1 a 5k
2 y2 c 5k
2 y3 b 10k
2 y4 d 10k
. . . .
. . . .
. . . .
有差异。 RS的值(如1,2,3,4,....)
现在我想要一个查询(仅采用 RS 的两个值,此处为 1,2),返回结果如下:
RS Value Measure Feature
1 x1 a 5k
2 y1 a 5k
1 x3 b 10k
2 y3 b 10k
. . . .
. . . .
即,我只想要那些具有共同度量和特征的行。
最佳答案
您可以将其表达为不存在
查询:
select t.*
from table t
where exists (select 1
from table t2
where t2.measure = t.measure and
t2.feature = t.feature and
t2.rs <> t.rs
);
关于MySQL查询从表中获取所需数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24181807/