MYSQL order by both Ascending and Descending sorting

后端 未结 2 948
清酒与你
清酒与你 2020-12-08 13:24

I have a mysql table with products.

The products have a category ID and a name.

What I\'d like to do is order by category id first descending order and then

相关标签:
2条回答
  • 2020-12-08 14:06

    You can do that in this way:

    ORDER BY `products`.`product_category_id` DESC ,`naam` ASC
    

    Have a look at ORDER BY Optimization

    0 讨论(0)
  • 2020-12-08 14:06

    I don't understand what the meaning of ordering with the same column ASC and DESC in the same ORDER BY, but this how you can do it: naam DESC, naam ASC like so:

    ORDER BY `product_category_id` DESC,`naam` DESC, `naam` ASC
    
    0 讨论(0)
提交回复
热议问题