Your original query will not return any rows because
SELECT pid
FROM products
WHERE pid = 'p01' AND pid = 'p07';
Will always return no rows because the condition WHERE pid = 'p01' AND pid = 'p07'
will never be met.
What you should do is:
SELECT cid
FROM customers
WHERE cid IN (SELECT cid
FROM orders
WHERE pid IN (SELECT pid
FROM products
WHERE pid IN ('p01', 'p07')));
You can also use a JOIN:
SELECT DISTINCT C.cid
FROM customers AS C
INNER JOIN
orders AS O ON O.cid = C.cid
INNER JOIN
products AS P ON P.pid = O.pid
WHERE P.pid IN ('p01', 'p07')
If you do not want to use DISTINCT then you can do this:
SELECT C.cid
FROM customers AS C
WHERE EXISTS (SELECT O.cid
FROM orders AS O INNER JOIN
products AS P ON P.pid = O.pid
WHERE P.pid IN ('p01', 'p07') AND O.cid = C.cid)
based on your comment " It returns c001, c004, and c006, but customer c004 had only ordered one of the products (p01) not both (p07 and p01)" I think you will need to do this:
SELECT C.cid
FROM customers AS C
WHERE EXISTS (SELECT O.cid
FROM orders AS O INNER JOIN
products AS P ON P.pid = O.pid
WHERE P.pid IN ('p07') AND O.cid = C.cid) AND
EXISTS (SELECT O.cid
FROM orders AS O INNER JOIN
products AS P ON P.pid = O.pid
WHERE P.pid IN ('p01') AND O.cid = C.cid )