0
我有这样的MySQL查询MySQL的ORDER BY不排序正确
SELECT list.*, brand.displayed_text AS brandName
FROM itemmaster_list AS list
LEFT JOIN brand_lists AS brand ON brand.cid = list.brandcode
WHERE brandcode = 'abc'
ORDER BY list.orderpriority DESC, list.date_added DESC , list.cid DESC
当你运行这个在PHPMySQL它返回由该领域的正确排序数据[list.orderpriority]
但是当你在我的PHP代码运行(直通浏览器),它由现场数据排序[list.date_added]
PHP代码
$result_item = mysql_query("SELECT list.*, brand.displayed_text AS brandName FROM itemmaster_list
AS list LEFT JOIN brand_lists AS brand ON brand.cid = list.brandcode WHERE brandcode = 'abc'
ORDER BY list.orderpriority DESC, list.date_added DESC , list.cid DESC") or die(mysql_error());
if (mysql_num_rows($result_item) > 0) {
while($row_item = mysql_fetch_array($result_item)) {
[echo here the records]
}
}
你能提供你的PHP代码吗? – PoeHaH 2012-07-28 10:04:07
对于初学者,您在SQL查询中缺少关闭'“'... – verdesmarald 2012-07-28 10:10:27