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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T06:50:50+00:00 2026-05-12T06:50:50+00:00

Updating by @Cesar ‘s request. Hope I understood what you want, if not, please

  • 0

Updating by @Cesar‘s request. Hope I understood what you want, if not, please revert. Quassnoi.

If I make an SQL query like this: SELECT * FROM TABLE_NAME WHERE b IN (2, 7) AND c IN (3, 9), can I assume that MySQL will match only pairs from elements with same number in each list?

That is, (2, 3), (7, 9), …?

For example, suppose we have a table like this:

 +----------+----------+----------+
 |    PK    |     b    |     c    |
 +----------+----------+----------+
 |     1    |     2    |     3    |
 +----------+----------+----------+
 |     2    |     5    |     4    |
 +----------+----------+----------+
 |     3    |     7    |     9    |
 +----------+----------+----------+
 |     4    |     7    |     4    |
 +----------+----------+----------+
 |     5    |     2    |     9    |
 +----------+----------+----------+

Is it correct to assume that the only rows returned are 1 and 3 (and not 5)?

  • 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-12T06:50:50+00:00Added an answer on May 12, 2026 at 6:50 am
    SELECT * FROM TABLE_NAME WHERE b IN(5,7) AND c IN(4,4)
    

    This query will return rows, where b is either 5 or 7, AND c is 4.

    What do you mean by “evaluation in pairs?”

    Update:

    I’ll add one more row to the sample:

     +----------+----------+----------+
     |    PK    |     b    |     c    |
     +----------+----------+----------+
     |     1    |     2    |     3    |
     +----------+----------+----------+
     |     2    |     5    |     4    |
     +----------+----------+----------+
     |     3    |     7    |     9    |
     +----------+----------+----------+
     |     4    |     7    |     4    |
     +----------+----------+----------+
     |     5    |     2    |     9    |
     +----------+----------+----------+
    

    If you want to match the whole sets, you can use this syntax:

    SELECT  *
    FROM    table_name
    WHERE   (b, c) IN ((2, 3), (7, 9))
    

    This means: “return all rows where b is 2 and c is 3 at the same time, OR b is 7 and с is 9 at the same time.”

    In the example above, this query will return rows 1 and 3

    But if you rewrite this query the other way around, like this:

    SELECT  *
    FROM    table_name
    WHERE   b IN (2, 7)
            AND c IN (3, 9)
    

    , this will mean “return all rows where b is either 2 or 7, AND c is either 3 or 9).

    This will return rows 1, 3 and 5, since row 5 satisfies the condition for the second query but not for the first one.

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

Sidebar

Related Questions

I'm currently inserting/updating fields like this (if there's a better way, please say so
When updating a row, I want to have a built-in check to do some
When updating from subversion repository using tortoise svn client I get error looking like
While updating a DataTable to a SQL Server database I get the error message
After updating Ubuntu 10.4, I'm not able to build any projects with errno.h used
updating mysql connector from v3 to v5 caused Operation not allowed after ResultSet closed
Updating an old ASP/Access site for a client - I need SQL to add
Updating an object with MVC3 I have a model that I can modify, please
After updating the oracle the query below starts returning strange results, it should returns
Updating the question to below: Please see attached code. <h:form id=tblForm styleClass=formTblClass> <h3 style=text-align:

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.