I'm trying to solve this for quite a moment now and I don't seem to be able to do it by myself.
I'd like to store OPTIONS linked to IDs, and when needed, get the results that match all wanted OPTIONS. I thought about doing it this way:
ID | OPTION
aaa | 1
aaa | 2
aaa | 3
bbb | 1
bbb | 2
ccc | 1
ccc | 2
ccc | 5
ccc | 7
Where ID and OPTION are FOREIGN KEYS.
The final request would look like
options_wanted(1,2,5,7)
SELECT * FROM main_table
WHERE crit1=...
AND crit2=...
AND (ALL OPTIONS ARE FOUND IN options TABLE)
Can I make it work or should I change the implementation?
What do you suggest me?
EDIT:
Thanks to https://stackoverflow.com/a/7505147/2512108, I almost found what I want.
His query works but the last column only gives the 1st option alone. Is there a way to make it return ALL the options AVAILABLE (not only the wanted ones) ?