2
我有两个MySQL查询:排序MySQL查询
$sql = "SELECT * FROM content WHERE threadName LIKE '%$filter%' ORDER BY lastUpdated desc";
和
$sql = "SELECT * FROM content ORDER BY lastUpdated desc";
最终的结果是让所有的行从一个特定的表“内容”返回,但有那些匹配顶部的变量$ filter。有没有可能结合这两个单个查询或我应该使用JOIN?
............仍然没有运气。这是我目前有:
$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";
这给:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/andrew/public_html/PHP/threadDisplay.php on line 20
虽然单独使用时,第一部分(前盟)的作品。
我很害怕这个至今,看看我上面更新的代码。 – kalpaitch 2010-03-13 13:59:49
请参阅编辑。 – AxelEckenberger 2010-03-13 14:50:55