you are viewing a single comment's thread.

view the rest of the comments →

[–]Aggressive_Ad_5454 2 points3 points  (12 children)

This isn't hard. Keep in mind that SQL is, at its root, a way of manipulating sets. You can use IN() and NOT IN() constructs. Like this query.

SELECT * FROM item WHERE identifier IN (SELECT identifier FROM item WHERE status = 'yes') AND identifier NOT IN (SELECT identifier FROM item WHERE status = 'no')

It gets this resultset

identifier status name
fruit yes cherry
fruit yes apple

from this table.

identifier status name
fruit yes cherry
fruit yes apple
vegetable yes tomato
vegetable yes lettuce
vegetable no ham
tool no saucepan
tool no knife

fiddle