mysql UNION query not working
- by kalpaitch
What am I doing wrong with this:
$sql = "SELECT * FROM content WHERE threadName LIKE '%$filter%' ORDER BY lastUpdated desc UNION SELECT * FROM content WHERE threadName NOT LIKE '%$filter%' ORDER BY lastUpdated desc";
The first statement before the UNION works well on its own, but this one above returns:
mysql_fetch_array() warning - supplied argument is not a valid MySQL result resource
Am I right in believing that UNION will not return duplicate entries, in which case the second SELECT statement doesn't need to have the NOT LIKE but will just return everything that wasn't listed in the first statement.