Reputation: 2694
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 :
Upvotes: 1
Views: 109
Reputation: 315
You made mistake As Arif_suhail_123 said...
if you want speb_breadcrumb_id
in this order 255, 256, 257
... then change query
ORDER BY `spb_breadcrumb_id` ASC
Upvotes: 5
Reputation: 2509
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
Upvotes: 1