doutanggun9816 2014-10-25 06:13
浏览 34
已采纳

id desc对mysql命令的奇怪行为

I have some trouble while using mysql.

I do a standard request like I often do, and to this time there was no problem.

I'm trying to sort a request by Id desc, and it does not work.

Below is the request :

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

and below is the result, as you can see, the result is not ordered as expected, it should display 255, 256 and 257.

But now it display 256, then 257, then 255... all is wrong.

I do have an index on the id.

Anykind of help will be much appreciated.

below the showing of mysql :

enter image description here

  • 写回答

2条回答 默认 最新

  • douyouming9180 2014-10-25 06:22
    关注

    Note You are using ORDER BY on wrong column

    Because you are using ORDER BY on this column spb_breadcrumb_id_breadcrumb , This column has three value and they all are 76,76,76.

    Use it on this column which you want to order, which should be this according to the picture

    spb_breadcrumb_id this column has three value 256,257 and 255

    so change your this line like this

    ORDER BY `spb_breadcrumb_id` DESC
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 软件测试决策法疑问求解答
  • ¥15 win11 23H2删除推荐的项目,支持注册表等
  • ¥15 matlab 用yalmip搭建模型,cplex求解,线性化处理的方法
  • ¥15 qt6.6.3 基于百度云的语音识别 不会改
  • ¥15 关于#目标检测#的问题:大概就是类似后台自动检测某下架商品的库存,在他监测到该商品上架并且可以购买的瞬间点击立即购买下单
  • ¥15 神经网络怎么把隐含层变量融合到损失函数中?
  • ¥15 lingo18勾选global solver求解使用的算法
  • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行
  • ¥20 测距传感器数据手册i2c