Hi! Could we please enable some services and cookies to improve your experience and our website?

SQLize | PHPize | SQLtest

Online Sandbox for SQL and PHP: Write, Run, Test, and Share SQL Queries and PHP Code

A A A
Login    Share code      Blog   FAQ
Copy Format Clear
create table tbl (user_id int, entity_id int, entity_type int, entity_style int); insert into tbl values (1, 22, 0, 1), (1, 23, 0, 1), (1, 24, 0, 1), (1, 25, 0, 1), (2, 25, 0, 1), (2, 24, 0, 1), (3, 24, 0, 1); select user_id from tbl where entity_id in (24, 25) group by user_id having count(distinct entity_id) = 2;

Stuck with a problem? Got Error? Ask AI support!

Copy Clear