Mysql
 sql >> Datenbank >  >> RDS >> Mysql

Simulieren von ORDER BY FIELD() von MySQL in Postgresql

Ah, gahooa war so nah dran:

SELECT * FROM currency_codes
  ORDER BY
  CASE
    WHEN code='USD' THEN 1
    WHEN code='CAD' THEN 2
    WHEN code='AUD' THEN 3
    WHEN code='BBD' THEN 4
    WHEN code='EUR' THEN 5
    WHEN code='GBP' THEN 6
    ELSE 7
  END,name;