Answer the question
In order to leave comments, you need to log in
How to draw up a sample?
Good afternoon.
Please tell me how to make a selection.
There is a table
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
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 questionAsk a Question
731 491 924 answers to any question