Please login or register to vote for this query.

(click on this box to dismiss)

Raspberry Pi

Q&A for users and developers of hardware and software for Raspberry Pi

DECLARE @table AS TABLE (id INT, customer VARCHAR(50), product varchar(50));

INSERT INTO @table VALUES (1, 'Tizag', 'Pen'), (4, 'Gerald Garner', '19" LCD Screen'), (5, 'Tizag', '19" LCD Screen');

SELECT DISTINCT customer FROM @table t1
WHERE EXISTS (SELECT * FROM @table WHERE product = 'Pen' AND customer = t1.customer)
    AND EXISTS (SELECT * FROM @table WHERE product = '19" LCD Screen' AND customer = t1.customer)

Enter Parameters

Switch sites:
loading Hold tight while we fetch your results