I have a little problem writing a request.
With the data example below, i want to recover the archive_id that have a document_type_id = 18 and 20
+------------+------------------+ | archive_id | document_type_id | +------------+------------------+ | 1 | 20 | | 1 | 18 | | 3 | 20 | | 4 | 11 | | 2 | 23 | | 5 | 20 | | 6 | 23 | | 6 | 20 | | 6 | 18 | +------------+------------------+
Expected result :
+------------+ | archive_id | +------------+ | 1 | | 6 | +------------+
Same question but with document_type_id = 18, 20 and 23
Expected result :
+------------+ | archive_id | +------------+ | 6 | +------------+
Thank for your help
2
Answers
A simple having count would do the trick.
First case
https://dbfiddle.uk/MnjR_4a_
Second case
https://dbfiddle.uk/v9m3nPiq
For a general solution, you could for example use an array containing the
archive_id
s you are searching for: