SELECT * FROM case_study ORDER BY CASE WHEN expiry_date_case > CURDATE() THEN 3 WHEN expiry_date_case IS NULL THEN 2 WHEN expiry_date_case < CURDATE() THEN 1 END DESC
The above query works fine, but I want to sort items by the expiration date in ASC in one case and in DESC in one case. How to do this, there must be something like this
pseudo query
WHEN expiry_date_case > CURDATE() THEN 3 expiry_date_case ASC WHEN expiry_date_case IS NULL THEN 2 WHEN expiry_date_case < CURDATE() THEN 1 expiry_date_case DESC
php mysql
mask man
source share