Table1 has the following columns
problem
t1
t2
t1 and t2 are INT
problem is the result of the values from t1,t2
t1 can be 1,2,3,4,5
t2 can be 6,7,8,9,10
I could write an SQL query that says
SELECT * from Table1 WHERE (t1=1 OR t1=2 OR t1=3 OR t1=4 OR t1=5) AND (t2=6 OR t2=7 OR t2=8 OR t2=9 OR t2=10)
But instead of writing out the entire expression (shown above), I want to store it into another table (called Table2)
Table2 has the following columns
data_entered
data_results
data_entered is 1
data_results is a string with the following data “(t1=1 OR t1=2 OR t1=3 OR t1=4 OR t1=5)”
data_entered is 2
data_results is a string with the following data “(t2=6 OR t2=7 OR t2=8 OR t2=9 OR t2=10)”
so I want to create a QUERY where I could say
SELECT * from Table1 WHERE … (and specify data_entered) the results should be the same as the above mentioned SQL.
Please help.
Thanks
For your first query, you can use IN instead:
Then instead of storing sql code in table2, store each value in a seperate row.
Then you can do: