使用mysql时遇到了一些麻烦。
我像往常一样做标准请求,到目前为止没有问题。
我试图通过Id desc对请求进行排序,但它不起作用。
以下是请求:
SELECT `spb_breadcrumb_id` ,
`spb_breadcrumb_id_breadcrumb` ,
`spb_breadcrumb_base_url` ,
`spb_breadcrumb_label` ,
`spb_breadcrumb_link`
FROM `spb_breadcrumb`
WHERE `spb_breadcrumb_base_url` = 'index.php?p=maisons-en-bois&module=exemples_realisations'
ORDER BY `spb_breadcrumb_id_breadcrumb` DESC
以下是结果,如您所见,结果未按预期排序,它应显示255,256和257.
但现在它显示256,然后是257,然后是255 ......一切都错了。
我的id上有一个索引。
非常感谢任何帮助。
在mysql的显示下面:
答案 0 :(得分:5)
你犯了错误,因为Arif_suhail_123说...
如果您希望speb_breadcrumb_id
按此顺序255, 256, 257
...则更改查询
ORDER BY `spb_breadcrumb_id` ASC
答案 1 :(得分:1)
注意您在错误的列
上使用ORDER BY
因为您在此列ORDER BY
上使用spb_breadcrumb_id_breadcrumb
,所以此列有三个值,它们都是76,76,76。
在您要订购的此列上使用它,根据图片
应该是这个 spb_breadcrumb_id
此列有三个值256,257 and 255
所以改变你的这一行
ORDER BY `spb_breadcrumb_id` DESC