I often use:
$result = mysql_query($query) or die( mysql_error());
if ($idr = mysql_fetch_array($result))
{
do
.....
}while ($idr = mysql_fetch_array($result));
}
the above code to retrieve data from MySQL. If I want to get another set of sql result, I have to use this block of code again with different sql statement.
Is there a way I can merge new SQL with existing one, and let it return combined result so that I don't have to change anything in PHP part?
For example, if I have SQL:
SQL1: select * from book where title=....
and I want $result set also return values that is from
SQL2: select * from book where author=...
I know I could do where title=... OR author=...
but is there a way I can let it return result of SQL1 first, followed by SQL2?
I don't want to change PHP code, so how do I merge these two SQL and return combined results?
Please help