Created
February 7, 2023 14:21
-
-
Save luckydevilru/5a4511f34bb1a051db48bbc59f21754c to your computer and use it in GitHub Desktop.
приоритетная сортировка по заголовку mysql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT id, name, description | |
FROM products | |
ORDER BY CASE WHEN name LIKE '%string%' THEN 2 WHEN description LIKE '%string%' THEN 1 ELSE 0 END DESC, name |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment