MySQL ORDER BY没有正确排序

时间:2012-07-28 10:02:14

标签: mysql

我有这个mySQL查询

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]

排序的CORRECTLY数据

但是当你在我的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]
    }
}

1 个答案:

答案 0 :(得分:0)

问题解决了。

事实证明我们的主机在不告诉我们的情况下将我们转移到新服务器,因此我们有两个数据库,PHP文件连接到新数据库,而phpMySQL Im玩的是旧数据库,这就是为什么我得到一个不同的结果