Forum Moderators: coopster

Message Too Old, No Replies

Union

Using MySQL;s UNION in PHP

         

trebian

9:44 pm on Jun 1, 2004 (gmt 0)

10+ Year Member



Hello forum:

ISSUE:
The Mysql UNION code works directly with the mysql.exe -direct with db-- but when put in a PHP code, errors out.


$resp = mysql_query("(SELECT account, 'GT' as status, count(ID) as total FROM tblx GROUP BY account HAVING count(ID) > 10) UNION ("(SELECT account, 'LT' as status, count(ID) as total FROM tblx GROUP BY account HAVING count(ID) < 10)");

while ($row = mysql_fetch_array($resp)) {
print ("the status is: " . $row{'status'};
}

Any insight?

TIA

ergophobe

6:16 pm on Jun 2, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



For starters, your double quotes don't match.