'Looking for a query that only returns results with matching IDs

sorry in advance for beeing stupid :)

I have the following tables tables

I want to search for different values ​​and then get a group_id back that contains all the values ​​I'm looking for. Is that possible, or does the structure have to be changed for this?



Solution 1:[1]

For example if you only need to select group_id for which value A, B and C all are available you can use group by with aggregation like below:

SELECT group_id FROM envelope_characteristic
WHERE value IN ('A','B','C');
GROUP BY GROUP_ID
HAVING COUNT(DISTINCT VALUE)=3

Solution 2:[2]

As far as I can tell your existing structure should be OK. You could write a query that goes like this:

SELECT group_id FROM envelope_characteristic WHERE value IN (...);

It'll return all the group_ids that contain the values you're searching for.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Kazi Mohammad Ali Nur
Solution 2 JeanRemyDuboc