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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T02:36:01+00:00 2026-06-13T02:36:01+00:00

I have a mysql database (item_preset) with the following table: +—–+———–+———+——-+ | id |

  • 0

I have a mysql database (item_preset) with the following table:

+-----+-----------+---------+-------+ 
| id  | preset_id | item_id | value |
+-----+-----------+---------+-------+
| 1   | 1         | 1       | 2     | 
| 2   | 1         | 2       | 1     | 
| 3   | 1         | 4       | 60    | 
| 4   | 1         | 3       | 16    | 
| 5   | 1         | 3       | 17    | 
| 6   | 1         | 3       | 18    |
| 7   | 1         | 3       | 25    |
| 8   | 1         | 3       | 26    | 
| 9   | 1         | 3       | 27    | 
| 10  | 2         | 1       | 3     | 
| 11  | 2         | 2       | 0     | 
| 12  | 2         | 4       | 0     | 
| 13  | 2         | 3       | 16    | 
| 14  | 2         | 3       | 17    | 
| 15  | 2         | 3       | 19    | 
| 16  | 2         | 3       | 20    | 
| 17  | 2         | 3       | 21    | 
| 18  | 3         | 1       | 2     | 
| 19  | 3         | 2       | 0     | 
| 20  | 3         | 4       | 0     | 
| 21  | 3         | 3       | 25    | 
| 22  | 3         | 3       | 28    | 
| 23  | 4         | 1       | 1     | 
| 24  | 4         | 2       | 1     | 
| 25  | 4         | 4       | 120   | 
| 26  | 4         | 3       | 16    | 
| 27  | 4         | 3       | 17    |         
| 28  | 4         | 3       | 18    | 
| 29  | 4         | 3       | 22    | 
| 30  | 4         | 3       | 23    | 
| 31  | 4         | 3       | 24    | 
| 32  | 6         | 1       | 3     | 
| 33  | 6         | 2       | 1     | 
| 34  | 6         | 4       | 90    | 
| 35  | 6         | 3       | 18    | 
| 36  | 6         | 3       | 22    | 
| 37  | 6         | 3       | 23    | 
| 38  | 6         | 3       | 24    | 
| 39  | 6         | 3       | 29    | 
| 40  | 6         | 3       | 30    | 
+-----+-----------+---------+-------+

What I would like to do is get the distinct preset_id based on conditions from multiple rows.
eg to get preset_id 1 i need all the conditions to be true (item_id = 1 and value_id = 2), (item_id = 2 and value = 1), etc…

I have tried usintg the following:
select distinct preset_id from item_preset where (item_id = 1 and value = 2) and (item_id = 2 and value = 1) and (item_id = 4 and value = 60);

but get an Empty Set. If I try with Or’s instead of and I get all preset_ids that match any of the conditions.

Any Ideas?

Thanks

  • 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-13T02:36:02+00:00Added an answer on June 13, 2026 at 2:36 am

    You can try something like this:

        select distinct preset_id from item_preset 
    where preset_id in (select preset_id from item_preset where item_id = 1 and value = 2) 
    and preset_id in (select preset_id from item_preset where item_id = 2 and value = 1) 
    and preset_id in (select preset_id from item_preset where item_id = 4 and value = 60);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have mysql database structure like below: CREATE TABLE test ( id int(11) NOT
I have a MySQL database table called Participant that looks something like this: (idParticipant)
In a MySQL database I have a table with the following primary key PRIMARY
I have a MySQL database with the following table structure: TransactionType : Transaction_Amount, Transaction_ID,
I have mysql database like this id | code 1 | bok-1 2 |
I have a MySQL database where the table was set up to store the
I have a MySQL database and with a php function i made a table
I have created a mysql table with the following columns... item_price, discount, delivery_charge, grand_total
I have only one table in my mySql database for a very basic website
My table is being populated using ajax from a mysql database. I have a

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.