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

  • Home
  • SEARCH
  • 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 7058601
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:07:56+00:00 2026-05-28T04:07:56+00:00

I get data from IN query in this format SELECT * FROM wp_devices WHERE

  • 0

I get data from IN query in this format

SELECT * FROM wp_devices WHERE QID=’1′ and DId IN(36,71,37,39,38)

But they are displaying in this format DId IN(36,37,38,39,71) instead of DId IN(36,71,37,39,38).

What should I do ?

  • 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-28T04:07:56+00:00Added an answer on May 28, 2026 at 4:07 am

    You should add order by clause to your query.
    Because your order is a little bizarre you must to write case workflow code:

    SELECT * 
    FROM wp_devices 
    WHERE 
       QID='1' and 
       DId IN (36,71,37,39,38) 
    ORDER BY
       case DId
         when 36 then 1
         when 71 then 2
         when 37 then 3
         when 39 then 4
         when 38 then 5
       end
    

    I suppose that you work with mysql because you have another question that is tagged like this. Then you can simplify previous query using field function:

    SELECT * 
    FROM wp_devices 
    WHERE 
       QID='1' and 
       DId IN (36,71,37,39,38) 
    ORDER BY
       field( DId, 36,71,37,39,38 )
    

    Notice that field works with strings an an implicit type casting is maded.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using a SELECT query to get the data from a number of
I am testing a simple query to get data from an AS400 database. I
I am using this query for pagination string selectStatement = SELECT * FROM (
I'm trying to run this query: select * from activity where id = 9348927
I am extracting data from excel that is in this format product1 | unnamedcol2
So i have a query that is suppose to get me data from two
I get data from a 3rd party API that just gives me back a
How get data from mysql database? I use ASP.NET and C#.Previously, I used LINQ
I would like to get data from from different webpages such as addresses of
How to get data from the velocity page in a action class?

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.