hey guys
i'm having some problem with php and mysql UNION query
here is my code:
$result= mysql_query(" SELECT FROM table1 WHERE Post Code <=2000 AND State = 'NSW' ORDER BY Post Code DESC LIMIT 5
UNION
SELECT FROM table1 WHERE Post Code >=2000 AND State = 'NSW' ORDER BY Post Code ASC LIMIT 5 ");
if (!$rec = mysql_fetch_array($result)){
echo ("Sorry, no records found");
}
else {
do{
echo ($rec["Post Code"]);
}
while ($rec = mysql_fetch_array($result));
}
what i'm trying to do is search for post code that's in the database, and display all the postcode that is "<" then and ">" then postcode number 2000, and then limit the result to 5.
the above SQL statement works fine in mysql, but when i put it into php it's not working anymore,
i can get code above UNION working fine, but once include UNION and the code below union i get errors
can anyone help me
thanks