I have a mysql database with two tables, its a one-to-many relationship.
table1 has elements {A,B,C...,N}
table2 has elements {A1,A2,...,AX,B1,B2,...BX,C1,C2,C3,...,CX,...,N1,N1,N3,...,NX}
I made a query to table one and it returns a subset of elements ie. {A,D,T} (this subset could be large, 100 elements)
Now I want to make a query to the second table to get all the elements that map to the first subset and they need to be sorted by two columns.
What is the best way to make the second query when the size of the subset from the first query is dynamic?
Do I need a string with a bunch of ORs?
SELECT * FROM table2 WHERE ID = A or ID = D ..... ORDER BY X,Y
try this