I'm going to go with 'funky';
SELECT y.*
FROM my_table x
JOIN my_table y
ON y.id = x.id
AND y.feature <> x.feature
WHERE x.feature = 'one';
As Strawberry commented, you could use an inner join:
SELECT f2.feature
FROM feature f1
INNER JOIN feature f2 ON f1.id = f2.id AND f1.feature <> f2.feature
WHERE f1.feature='one'
One way to do this is with the exists
operator:
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')
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.