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 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

Could you help me to make this query faster. My query is workable, but
It seems that both of them could make the element move from its current
Is there a python lib that could make a 2-dimensional list of (R,G,B) data
How could I make a UIImage move from the bottom of the screen, to
I have a table that looks something like this: CREATE TABLE student_results(id integer, name
I have this code, which I would like to make as small as possible.
I'm trying to reference a field from the 1st select table in the 3rd
I have a good LINQ query that is working well, it returns a result
I would like to start my question by stating that this is a C++
I am curious how I could make a PHP script where you pass your

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.