I have a table Record (id, name). Then I have 10 different Method tables in each one there are few sub-methods.
So my tables look like:
One:
Record (id, name)
1, abc
2, fgt
3, ght
Two:
Method A (id, rec_id, meth_name)
1, 3, sub1_metha
2, 3, sub2_metha
3, 2, sub1_metha
4, 1, sub3_metha
....
Three:
Method Z,(id, rec_id, meth_name)
1, 2, sub1_methz
2, 1, sub4_methz
3, 2, sub3_methz
4, 3, sub1_methz
User needs to be able to search by sub_methods
with either AND
or ANY
operand.
I need to create 2 queries:
- To select all records that have all submethods specified by user.
- To select all records that have any submethods specified by user.
I feel like I'm missing something very obvious here (UNION
, JOIN
, 10 SELECT
s)?