I have table where item_id, property_id and value_id(value of property, concerning item) stored. It looks like this:
item_id property_id value_id
--------------------------------
001 p_001 aaa
001 p_002 bbb
001 p_003 ccc
002 p_001 zzz
002 p_002 bbb
002 p_003 ddd
003 p_001 yyy
003 p_002 bbb
003 p_003 ddd
So I want get items, that have values val = [bbb]
, for example, so it will be item_001, item_002 and item_003.
But now I want items, that have values val = [bbb, ccc]
, it will be item_001 only.
And now I want to get items, that have values val = [bbb, ddd]
, it will be obviously item_002 and item_003.
When val = [aaa,zzz]
it should output item_001 as well as item_002.
How can I achieve that?
I thought that there is simple SQL query, but I can't construct it properly.