Present the following tables:
create tables (id int, name text, ...);
create a thingsinboxes table (id int, box_id int, subject enum ('apple,' banana ',' orange ');
And the tables look like this:
Boxes:
id | name
1 | orangesOnly
2 | orangesOnly2
3 | orangesBananas
4 | misc
thingsinboxes:
id | box_id | thing
1 | 1 | orange
2 | 1 | orange
3 | 2 | orange
4 | 3 | orange
5 | 3 | banana
6 | 4 | orange
7 | 4 | apple
8 | 4 | banana
How to choose boxes containing at least one orange and nothing that is orange?
How is this scale if I have several hundred thousand boxes and maybe a million things in boxes?
SQL, , script.
postgres, mysql, , , , , mysql ( 6, ).