答案 0 :(得分:1)
我要去' funky&#39 ;;
SELECT y.*
FROM my_table x
JOIN my_table y
ON y.id = x.id
AND y.feature <> x.feature
WHERE x.feature = 'one';
答案 1 :(得分:1)
正如Strawberry评论的那样,你可以使用内连接:
SELECT f2.feature
FROM feature f1
INNER JOIN feature f2 ON f1.id = f2.id AND f1.feature <> f2.feature
WHERE f1.feature='one'
答案 2 :(得分:0)
执行此操作的一种方法是使用exists
运算符:
SELECT *
FROM features f_outer
WHERE EXISTS (SELECT *
FROM features f_inner
WHERE f_outer.id = f_inner.id AND
f_outer.feature != f_inner.feature AND
f_inner.feature = 'one')