Skip to main content
Added formatting around SQL.
Source Link
Vérace
  • 30.6k
  • 9
  • 71
  • 84
ORDER BY (case when `cat` = 'mgr' then 1 
when `cat` = 'dev' then 2 
else 3 end)

ORDER BY (case when cat = 'mgr' then 1 when cat = 'dev' then 2 else 3 end) ThisThis structure help me in Wordpress. For example to select custom posts first theh other: poster and project is custom SELECT post_type FROM wp_posts ORDER BY (case when post_type = 'poster' then 1 when post_type = 'project' then 2 else 3 end)

ORDER BY (case when cat = 'mgr' then 1 when cat = 'dev' then 2 else 3 end) This structure help me in Wordpress. For example to select custom posts first theh other: poster and project is custom SELECT post_type FROM wp_posts ORDER BY (case when post_type = 'poster' then 1 when post_type = 'project' then 2 else 3 end)

ORDER BY (case when `cat` = 'mgr' then 1 
when `cat` = 'dev' then 2 
else 3 end)

This structure help me in Wordpress. For example to select custom posts first theh other: poster and project is custom SELECT post_type FROM wp_posts ORDER BY (case when post_type = 'poster' then 1 when post_type = 'project' then 2 else 3 end)

Source Link

ORDER BY (case when cat = 'mgr' then 1 when cat = 'dev' then 2 else 3 end) This structure help me in Wordpress. For example to select custom posts first theh other: poster and project is custom SELECT post_type FROM wp_posts ORDER BY (case when post_type = 'poster' then 1 when post_type = 'project' then 2 else 3 end)