Answer the question
In order to leave comments, you need to log in
How to write SQL?
In short, I screwed up a little, now I need to come up with a crutch ... It is not possible to redo it in the next few months.
There is a table
And now I need to make a query that filters eid by patronymic = Pavlovich and place_award = Kolomna
And it turns out that if I make a query, then both eid = 1 and eid = 18 can get into the output. only eid = 1.
Answer the question
In order to leave comments, you need to log in
select eid
from t
where (key, value) in (('patronymic','Павлович'),('place_award','г.Коломна'))
group by eid
having count(eid) = 2
SELECT DISTINCT t1.eid
FROM
t t1
JOIN t t2 ON t2.eid = t1.eid AND t2.key = 'patronymic' AND t2.value='Павлович'
WHERE t1.key = 'place_award' AND t1.value = 'г.Коломна'
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question