Search multiple values in multiple columns
Personally I would create your table
- id
- result_id
- value
But with a single value in the value column. Now you can index on the value column and that should dramatically speed things up. Your query would then look like this:
SELECT result_id
FROM TableName
WHERE VALUE IN ('02','12','20')
GROUP BY result_id
HAVING COUNT(1) >= 3
One of the benefits of this is that you can now easily check for 1 match, 2 matches etc. You can also increase the number of items they could check to 50 and your table structure wouldn't have to change.
That being said right now that won't work for you. Right now I would use something like this:
SELECT *
FROM TableName
WHERE '02' IN (Number_1, Number_2, Number_3, Number_4, Number_5)
AND '12' IN (Number_1, Number_2, Number_3, Number_4, Number_5)
AND '20' IN (Number_1, Number_2, Number_3, Number_4, Number_5)