if (select * from table where x=1) returns 0 rows then i need (select * from table where x=2 [or some other query]). is it possible to do this in a single MYSQL query with a conditional statement?
edit: all answers with 'UNION' work but only if both queries selects from the same table (or tables with the same number of columns). What if the second query is applied on a different table with joins?
let me write down the my queries to make the question more clear:
1st: SELECT table1.a, table2.b from table1 LEFT JOIN table2 ON table2.x= table1.x WHERE ..... if the result from the 1st one is null then 2nd: SELECT table1.a FROM table1 WHERE ....
I will be using the rows from the 1st query if it returns any, otherwise the 2nd one will be used.