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 7804973
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T02:04:34+00:00 2026-06-02T02:04:34+00:00

I am stuck with FIND_IN_SET function in MYSQL 5.5, For example: Please check below

  • 0

I am stuck with FIND_IN_SET function in MYSQL 5.5, For example:

Please check below query, considering 10,9,5,8,21 are user id’s

SELECT u.user_id,u.first_name,u.last_name
FROM user u 
WHERE 
u.is_active = 'Y'       
AND FIND_IN_SET(u.user_id,'10,9,5,8,21');

When I fire this query it give me results in Ascending order of user id’s that is in

5
8
9
10
21

I want in same order like I entered

10
9
5
8
21

Is there any way to achieve it?

STORED PROCEDURE

DROP PROCEDURE IF EXISTS databaseName.procName;
DELIMITER //
CREATE PROCEDURE databaseName.procName(IN ZoneIDs LONGTEXT)

BEGIN       
        SELECT u.user_id,u.first_name,u.last_name

        FROM user u     
        WHERE u.is_active = 'Y'
        AND FIND_IN_SET(u.user_id,ZoneIDs); 

END //
DELIMITER ;
  • 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-06-02T02:04:35+00:00Added an answer on June 2, 2026 at 2:04 am

    Try using it like this :

    SELECT u.user_id,u.first_name,u.last_name
    FROM user u 
    WHERE u.is_active = 'Y' and u.user_id IN (10,9,5,8,21)
    ORDER BY FIND_IN_SET(u.user_id,'10,9,5,8,21');
    

    This uses IN to only select data where u.userid is in that list and then orders by your specific order using find_in_set

    FIND_IN_SET returns the index of the first argument in the second argument – so I’m very surprised your query even worked …..

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

Sidebar

Related Questions

I am using C# application to authenticate and check Active Directory user which locates
I've got stuck in a problem with gflags when trying to find some memory
I'm really stuck trying to find out how to force a programmatic refresh of
I just stuck at this and cannot find solution. I would like to try
I am stuck on this issue and cannot seem to find a way around
I have some controller logic: public function seafood() { $this->set('title', 'Seafood restaurants in and
Seem to be stuck trying to only update images in a selected div, when
I'm experimenting with Comet and I'm stuck with implementing it via a hidden IFrame
I'm stuck at this part... I'm trying to get the ID to be included
I am using python and I am trying to use the set_colorkey function from

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.