Skip to content

Instantly share code, notes, and snippets.

@SauloSilva
Created November 19, 2013 14:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save SauloSilva/7546508 to your computer and use it in GitHub Desktop.
Save SauloSilva/7546508 to your computer and use it in GitHub Desktop.
sql case
SELECT STRAIGHT_JOIN categories.id, categories.title, categories.game_count, categories.display_order FROM `categories` INNER JOIN `category_namespaces` ON `category_namespaces`.`category_id` = `categories`.`id` WHERE `categories`.`type` IN ('ClickJogos::GameCategory') AND `categories`.`published` = 1 AND (category_namespaces.namespace = 'jgo') ORDER BY
CASE
WHEN categories.id LIKE '447%' THEN 1
WHEN categories.id LIKE '448%' THEN 2
ELSE 3
END, categories.game_count DESC;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment