Skip to content

Instantly share code, notes, and snippets.

@luckydevilru
Created February 7, 2023 14:21
Show Gist options
  • Save luckydevilru/5a4511f34bb1a051db48bbc59f21754c to your computer and use it in GitHub Desktop.
Save luckydevilru/5a4511f34bb1a051db48bbc59f21754c to your computer and use it in GitHub Desktop.
приоритетная сортировка по заголовку mysql
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