The WHERE clause can evaluate conditions on only one row from a given table at a time. You cannot make a span condition multiple lines.
But you can use self-join to match multiple rows from one table to one row in the result set, so you can apply a condition that includes both.
SELECT t1.pid FROM table t1 JOIN table t2 ON t1.pid=t2.pid WHERE t1.value = 3 AND t2.value = 9;
An alternative solution is to use GROUP BY and count different values:
SELECT t.pid FROM table t WHERE t.value IN (3,9) GROUP BY t.pid HAVING COUNT(DISTINCT t.value) = 2;
source share