Skip to content

Instantly share code, notes, and snippets.

@pioz
Created September 29, 2022 08:20
Show Gist options
  • Save pioz/8b966493bf24f39708481f2af59d27b3 to your computer and use it in GitHub Desktop.
Save pioz/8b966493bf24f39708481f2af59d27b3 to your computer and use it in GitHub Desktop.
Select records by ids and order by ids order
SELECT id FROM products WHERE id IN (2,1) ORDER BY array_position(array[2,1], id);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment