MySQL按更大的ID排序

时间:2014-01-19 19:13:55

标签: php mysql

如何下​​订单从最大到最低?

我正在使用:

mysqli_query($con, "SELECT * FROM builds 
                    WHERE approved = 'yes' AND ORDER BY build_id LIMIT 0, 10");

但是我发现了这个错误:

 Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in C:\wamp\www\pcbuilds\index.php on line 9

任何使其有效的方法?

2 个答案:

答案 0 :(得分:1)

您的查询看起来有误,您单独使用AND。删除AND

  SELECT * FROM builds 
                WHERE approved = 'yes'  ORDER BY build_id DESC LIMIT 0, 10

答案 1 :(得分:0)

您可以使用desc关键字来获取从最大到最低的订单:

SELECT *
FROM builds 
WHERE approved = 'yes'
ORDER BY build_id DESC
LIMIT 0, 10;