D
D
DomowDenis2020-01-15 17:03:44
MySQL
DomowDenis, 2020-01-15 17:03:44

Change ORDER BY logic?

Kind.
There is a query like this
SELECT * FROM product WHERE product .product_category = '2' ORDER BY product_subgroup
The problem is that product_subgroup is a character (A,B,C, etc.). Everything would suit, but there is a record A-, which should be ahead of A. That's the question - are there any options for how to change the sorting logic, I really don't want to enter another field in the table

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Sviridov, 2020-01-15
@DomowDenis

Is that how it works?

SELECT * FROM product
    WHERE product .product_category = '2' 
ORDER BY (product_subgroup='A'), product_subgroup

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question