I have a table which has many columns but there are two main columns called District and State. My sql query is as follows.
$query = "SELECT * FROM table WHERE District = '" . $var . "' ORDER BY Date DESC";
this query returns me data from the district column.
Now this is what I want.In some rows the District column is empty, so in that case I want the query to lift data from State column. Is that possible?
Can that be done in mysql query or will I have to write something in php?
what do you mean by empty? If it is
NULLthen you should useCOALESCEbut if it is empty as
''. then