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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T16:13:19+00:00 2026-05-13T16:13:19+00:00

This might not be very sensible, but I’ld like to let MySQL return me

  • 0

This might not be very sensible, but I’ld like to let MySQL return me the exact duplicate rows if there are duplicate criteria in the WHERE IN clause. Is this possible?

Take this example:

SELECT
   columns
FROM
   table
WHERE
   id IN( 1, 2, 3, 4, 5, 1, 2, 5, 5)

I’ld like MySQL to return me rows with id 5 three times, id’s 1 and 2 twice, and 3 and 4 once.

As the lenght of the IN arguments, as well as the duplicate count (once, twice, three times, etc.), will be arbitrary I don’t want to rely on UNION or JOIN. Is something like this possible otherwise?

  • 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-13T16:13:19+00:00Added an answer on May 13, 2026 at 4:13 pm

    I’m not sure why you want to ban JOIN as its fairly essential to SQL. It’s like banning function calls in a functional language.

    A good way to solve this is to create a result set containing the ids you want to return and join with it. Here’s one way to do it:

    SELECT Table1.*
    FROM Table1
    JOIN (SELECT 1 AS id
          UNION ALL SELECT 2
          UNION ALL SELECT 3
          UNION ALL SELECT 4
          UNION ALL SELECT 5
          UNION ALL SELECT 1
          UNION ALL SELECT 2
          UNION ALL SELECT 5
          UNION ALL SELECT 5) AS T1
    ON Table1.id = T1.id
    

    I’m not sure if you have considered this method? It has none of the problems that you seem to be afraid of.

    If you ban joins you can’t do this unless you use a stored procedure, which I’d say is worse than joining.

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

Sidebar

Related Questions

This question might not seem programming related at first, but let me explain. I'm
This might be a very simple thing in jquery but I am not able
This might very well be very stupid question, but I can not find QTabBar
This might seem like a stupid question I admit. But I'm in a small
This might be on the discussy side, but I would really like to hear
This might sound like a little bit of a crazy question, but how can
I'm not very used to javascript's prototyping syntax so this might be very simple.
This might be a very silly / stupid question, but, my defence is that
This may sound very weird, but let's start with an example: <my:MagicWidget ui:field=someFieldName fieldName=someFieldName/>
This might be a very stupid question, but I still dont completely understand and

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.