select - Matching at least one of each value in MySQL -


i've got 2 tables, want select entries 1 table, there entries in second table list of items.

for example:

entry

id=1 requirements=(1,2,3)  id=2 requirements=(1,3,5) 

submission

id=1 entry=1 requirement=1  id=2 entry=2 requirement=2  id=3 entry=3 requirement=3 

would select entry id=1, not entry id=2 (so where in doesn't job)

*edit actual datasets:

insert submission (entry_id, requirement_id, submission_id) values (17, 1, 1), (43, 1, 2), (57, 0, 3), (57, 0, 4), (1, 1, 5), (26, 1, 6), (40, 1, 7), (40, 1, 8), (40, 1, 9), (40, 1, 10), (85, 1, 11), (94, 1, 12), (114, 0, 13), (32, 1, 14), (34, 0, 15);

insert entry (entry_id, category_id) values (1, 2), (2, 1), (3, 1), (4, 1), (5, 2), (6, 1), (7, 1), (8, 1), (9, 1), (10, 1), (11, 1), (12, 1), (13, 1), (14, 1), (15, 1);

insert category (category_id, requirement) values (1, '1,2,3'), (2, '1,2,4,5,6'), (3, '1,2,4,5,6');

find rows in table 1 there 3 matching rows in table 2:

select   table1.id   table1 inner join   table2 on   table1.somecol = table2.somecol group   table1.id having   count(*) = 3 

i'd write actual query data can't decipher question.


Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -