My target DBMS's are both Oracle and MySQL
SELECT
users.*
, hr_orders.position_label
, hr_orders.is_boss
, deps.label AS dep_label -- preprocessor removes AS when using Orcale
, users.id IN (?) AS show_on_top -- Orcale doesn't accept this IN thing
FROM
-- some joins here
WHERE
-- some filters
Is it possible to give cross-DBMS equvalent of this query?
UPDATE
Ok, it ruins the logic, the guy before me wanted always show some users on top,
WHERE
users.fake = 0
AND (
users.id IN (?)
OR
-- some more detailed filters
)
ORDER BY
IF (users.id IN (?), 1, 2), users.label
where ? is parameter referring to top users.
This show_on_top field is needed to highlight top records later.
Therefore, if I move IN to where clause, only users shown on top will be selected, not the rest.
Splitting the query into two and combining users list in code still looks ugly to me.