A case of relational-division. See:
This query typically more efficient than what has been suggested so far:
SELECT id
FROM (SELECT id FROM tbl WHERE name = 'value1' AND value = 1) t1
JOIN (SELECT id FROM tbl WHERE name = 'value2' AND value = 2) t2 USING (id);
Or equivalent (results in identical query plan):
SELECT id
FROM tbl t1
JOIN tbl t2 USING (id)
WHERE t1.name = 'value1' AND t1.value = 1
AND t2.name = 'value2' AND t2.value = 2;
db<>fiddle here
Not enforcing uniqueness in the query (like other answers do) as I assume one or more constraints in the table already doing so.
Have a "covering" index on (name, value, id)
. Optimized index variations are possible, depending on your undisclosed table definition.
But first reconsider your relational design if you are in a position to change it. EAV models are typically sub-optimal. See: