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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T18:04:22+00:00 2026-05-14T18:04:22+00:00

How could I make this kind of query e.g. in MySQL SELECT * FROM

  • 0

How could I make this kind of query e.g. in MySQL

SELECT * FROM Table t 
WHERE t.a IN (1,2,3) 
AND t.b IN (4,5,6) 
AND t.c IN (7,8,9) ...

so that the result would contain only the three rows:

t.a|t.b|t.c
---+---+---
 1 | 4 | 7
 2 | 5 | 8
 3 | 6 | 9

The above query of course returns all the combinations of the values in the IN clauses but I would like to get just the ones where the first elements of each tuple match, second elements of each tuple match and so on.

Is there any efficient way to do this?

By the way is there some common term for this kind of query or concept? I’m having hard time coming up with the question’s title because I can’t put this into words..

  • 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-14T18:04:22+00:00Added an answer on May 14, 2026 at 6:04 pm
    SELECT  *
    FROM    mytable
    WHERE   (a, b, c) IN ((1, 4, 7), (2, 5, 8), (3, 6, 9))
    

    , or a more index-friendly solution:

    SELECT  *
    FROM    mytable
    WHERE   (a, b, c)  = (1, 4, 7)
            OR (a, b, c)  = (2, 5, 8)
            OR (a, b, c)  = (3, 6, 9)
    

    Unfortunately, MySQL does not use the indexes for record types in the IN clauses.

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

Sidebar

Related Questions

my question is, wether or not this is possible, and if so, how would
I have an SQL db with about 200,000 words. I need a query which
I have a class that contains an Enum to do calculation. Each Enum uses
I know this sounds strange, mixing CDI (Weld) and Spring for the controller. But
So im trying to make a integration between my XenForo forum and Source Mod
I'm trying to make the following work on my Debian computers and one OS
While reading some materials on data structure design for sparse vectors, the authors make
Possible Duplicate: Why Option[T] ? I am a newbie on Scala and I can't
I am making a cross-domain JSON(P) call by using JavaScript to add a <script>
I'm thinking of saving uploaded docs to a folder outside the webroot and feeding

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.