I am new to MySQl and not sure if this is possible or not. Let me put it across for some help. I would like to have a query which
can check a condition and decide on one of the two ‘select’ queries to be executed. Some thing like this,
if(select count(*) as test_count from test_table > '0' , select query on True , select query on false);
Can something like this be done in a single query?
without knowing what your two queries look like, i will guess that it would probably be better to do the logic with your application language (e.g. php)
p.s. did you know we have a special forum just for mysql?
Yes, that is definitely one option. But I thought if all that could happen in a single query then it would be better.
Sorry if it was not clear. Let me explain ,
I have two tables,
Table 1: with fields is_valued and name
The table has this data :
1 - name1
1 - name2
0 - name3
1 - name4
0 - name5
Table 2: with fields is_valued and name
The table has this data :
1 - name1
1 - name2
1 - name3
1 - name4
1 - name5
So, i want a single select query that can give me all data of table1 or of table2 based on whether ‘count(*) from table1 where is_valued > 0’
is true or false respectively.
I had implemented the same before I wanted to know if we can do something like that in a single query. I know believe that is the only way we can do what i want. Thanks again :)