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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T20:40:26+00:00 2026-06-14T20:40:26+00:00

I have a table: item_id | property_id | value | ================================ 1 | 100

  • 0

I have a table:

item_id  | property_id | value |
================================
1        |      100    |   1   |
1        |      101    |   1   |
1        |      102    |   0   |
2        |      100    |   1   |
2        |      101    |   1   |
2        |      102    |   1   |
2        |      120    | black |
3        |      100    |   1   |
3        |      101    |   0   |
3        |      102    |   1   |
4        |      121    |  big  |
...

I would like to perform “AND” search by a form with multiple checkboxes and select menus (each checkbox and select menu have name like ‘property_id’).

Example:

  1. When I check checkbox 100 and 101, desire result of query is item_id = 1, 2.
  2. When I check checkbox 100, 101 and choose ‘black’ from select menu 120, desire result is item_id = 2.
  3. When I check checkbox 100, 101, choose ‘black’ from select menu 120, and choose ‘big’ from select menu 121, desire result is item_id = NULL.

Number of checked properties (checkboxes and selectmenus) may vary.

I tried:

SELECT item_id
FROM yourtable
WHERE property_id IN (100, 101)
AND value = 1
GROUP BY item_id
HAVING COUNT(DISTINCT property_id) = 2

But it’s only for checkboxes and values 0 or 1. I have problem to implement it with select menus (example 2. or 3.)

I hope that explains what I’m trying to do.
Thanks in advance!

  • 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-14T20:40:27+00:00Added an answer on June 14, 2026 at 8:40 pm

    With minimum changes to your query:

    SELECT item_id
    FROM yourtable
    WHERE property_id IN (100, 101)
      AND value = 1
       OR property_id = 120 
      AND value = 'black'
    GROUP BY item_id
    HAVING COUNT(DISTINCT property_id) = 3 ;
    

    which is equivalent to:

    SELECT item_id
    FROM yourtable
    WHERE property_id = 100  AND  value = 1 
       OR property_id = 101  AND  value = 1
       OR property_id = 120  AND  value = 'black'
    GROUP BY item_id
    HAVING COUNT(DISTINCT property_id) = 3 ;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table with fields like this: Item Category Year Month Value I
I have a table Transactions(store_id, item_id, price). I want to find store_id's which sell
I have a table called 'MyTable' that looks like: ID | Item | Type
Suppose I have a table Item (Id int Primary Key, Number INT) having records
I have a table of items. item has id, score 1, score 2. I
I have three tables filters (id, name) items(item_id, name) items_filters(item_id, filter_id, value_id) values(id, filter_id,
I have three mysql tables items =========== id title items_in_categories ============================ id item_id category_id
I have a table full of items that each have a unique ItemID .
i have this three tables. Table: Item Columns: ItemID, Title, Content, NoChange (Date) Table:
I am using MYSQL and PHP. I have a table called item. Two of

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.