So I have a table, lets call it MAIN table, it has the following example columns
Name,
Code_1,
Code_2,
Code_3,
Code_4,
Code_5
(in my real example there's 25 Code columns)
I have a set of 300 codes that I inserted into a temporary table, what would be the best way to get the rows from the MAIN table where it matches a code from the temporary table?
Here's what I have so far that works, but it seems extremely inefficient
SELECT * FROM MAIN WHERE (CODE_1 IN (SELECT CODE FROM TMP_TABLE)
OR CODE_2 IN(SELECT CODE FROM TMP_TABLE)
OR CODE_3 IN (SELECT CODE FROM TMP_TABLE)
OR CODE_4 IN (SELECT CODE FROM TMP_TABLE)
OR CODE_5 IN (SELECT CODE FROM TMP_TABLE))