I have a table with two columns that are foreign keys (think in userID(int) : orderID(int) for example), and I have to know if orders 2, 3, 4, 5 exists for a user ID, in a where clause of a big query.
I need to optimize my database
SELECT table1.myrow FROM table1, table2
WHERE table1.myrow = table2.myrow
AND 1 IN (SELECT myRoww from table2 WHERE table2.id = table1.myrow)
AND 2 IN (SELECT myRoww from table2 WHERE table2.id = table1.myrow)
AND 3 IN (SELECT myRoww from table2 WHERE table2.id = table1.myrow)
I want to do something like this:
AND (SELECT * from mytable) IN (SELECT myRoww from table2 WHERE table2.id = table1.myrow)
How can I determine if my multiple value list exists for an ID? the rows i'm requesting are relations that consist in only a table with two foreign keys.
My relations:
Need to know if CONVOCATORIA_SECTOR have X relations for a CONVOCATORIAS(id_bdns_Conv)
