E
E
enigma20302018-09-06 12:25:46
MySQL
enigma2030, 2018-09-06 12:25:46

How to draw up a sample?

Good afternoon.
Please tell me how to make a selection.
There is a table
5b90ef6de41ad551456213.png
If, ​​for example, the input parameters property_id = 1 and value = test11
Then the result will be records 1 and 3.
But we want to refine the selection by adding property_id = 2 and value = test12, getting (property_id = 1 and value = test11) and (property_id = 2 and value = test12)
As a result, we want to get records 1 and 2. But we get nothing. What is wrong? And how can this selection be made?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Entelis, 2018-09-06
@enigma2030

Just today there was such a question How to search in a SQL database by groups?
In your case the request would be:

select 
   `offer_id`
from `table`
where 
   (`property_id` = "1" and `value` ="test11")
   OR
   (`property_id` = "2" and `value` ="test12")
group by `offer_id`
having count(`id`) = 2

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question