Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1035295
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T14:31:14+00:00 2026-05-16T14:31:14+00:00

My target DBMS’s are both Oracle and MySQL SELECT users.* , hr_orders.position_label , hr_orders.is_boss

  • 0

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 Oracle
  , users.id IN (?) AS show_on_top -- Oracle doesn't accept this IN thing
 FROM
  -- some joins here
 WHERE
  -- some filters

Is it possible to give cross-DBMS equivalent 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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T14:31:15+00:00Added an answer on May 16, 2026 at 2:31 pm

    You should put the IN into the WHERE clause

    SELECT
      users.*
      , hr_orders.position_label
      , hr_orders.is_boss
      , deps.label AS dep_label        
      , users.id  AS show_on_top 
     FROM
      -- some joins here
     WHERE
      -- some filters
      AND users.id IN (?,?,?)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to target an HTML element when BOTH the id and class selectors
My target DB is MySQL, but lets try to look at this problem more
Im currently porting a MySQL db to another DBMS. I encountered the following query
Target application is a medium-sized website built to support several hundred to several thousand
Target failed to run: Remote exception encountered: Faild to get task for pid 3103
The target machine is running Ububtu server 8.04. Here's the tramp output: tramp: Opening
The target language is C/C++ and the program has only to work on Linux,
setTimeout(target.mousedown, 200) doesn't seem to work. I can do setTimeout(target.mousedown(), 200) , but this
(The target browser is IE8) I have a div that contains a list of
On an embedded target I use far pointers to access some parts of the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.