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 users (id int, user_id int, a_id int, b_id int); insert into users values (1, 1, 2, 4),(5, 1, 7, 5),(7, 1, 3, 4),(8, 1, 9, 5); select row.user_id, count(*) matches_row_count from users user_row join users row on (user_row.a_id = row.a_id) and (user_row.b_id = row.b_id) and (user_row.id != row.user_id) where user_row.user_id = 1 group by row.user_id;

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

Copy Clear