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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T04:56:46+00:00 2026-06-12T04:56:46+00:00

From my understanding, IN works like this: $arrayName = array(1, 2, 3); SELECT *

  • 0

From my understanding, IN works like this:

$arrayName = array(1, 2, 3);

SELECT * 
FROM tableName 
WHERE productID IN ($arrayName)

is the equivalent of:

SELECT * 
FROM tableName 
WHERE productID = 1 OR productID = 2 OR productID = 3

I’m wondering if there’s a SQL function that works like IN but uses AND in place of OR to compare to an array. Something that would expand to this:

SELECT * 
FROM tableName 
WHERE productID = 1 AND productID = 2 AND productID = 3

Not that it’s necessary, but for context I’m simply creating a sort list for some search results that are being populated on a PHP page via jQuery. I can do what I need with PHP, I’ll simply create the query dynamically depending on what options the user has selected, but I’d rather use an intelligent SQL function if possible.

***EDIT: Thanks everyone for the help. I explained my problem very poorly and you were still able to sort it out, which I appreciate. I found that someone else had asked this question more eloquently and received an answer that I can use:

Is there something in MySQL like IN but which uses AND instead of OR?

I’m trying to figure out how to accept an answer and close this but I’m having a bit of trouble…

  • 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-12T04:56:47+00:00Added an answer on June 12, 2026 at 4:56 am

    You cannot possibly do this,

    SELECT * 
    FROM tableName 
    WHERE productID = 1 AND productID = 2 AND productID = 3
    

    the condition will always returns false because a row can have only one value on its column, the alternative way to do this is by grouping the result, ex.

    SELECT colName
    FROM tableName
    WHERE productID IN (1,2,3)
    GROUP BY colName
    HAVING COUNT(DISTINCT colName) = 3
    

    by having a condition HAVING COUNT(DISTINCT colName) = 3, this means that the instance of a record must be equal to the total count of parameters supplied on IN clause.

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

Sidebar

Related Questions

I'm not quite understanding how this works. Passing parameters from my entity objects works
From my understanding of the docs this general approach should work: begin try1 rescue
I'm having a really difficult time understanding how this all works together. I've fiddled
I've got a delegate statement that works like so: $(body).delegate(tr[type='option'],'mouseenter',function(){ The problem is that
From my understanding of the manual for DECIMAL in the mysql docs, it states
From my understanding, the soft keyboard is actually a dialog window that underlies all
From my understanding, each of these methods: get() and put() are atomic. But, when
From my understanding by reading several articles I assumed Process Address Space(PAS) and Virtual
MariaDB 5.3 introduced dynamic columns. From my understanding the next version of mysql should
From what little understanding of Cassandra I have, it seems that data locality is

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.