SQLize Online / PHPize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
create table users ( id int primary key auto_increment, name varchar(255) unique ); create table chats ( id int primary key auto_increment ); create table chat_user ( id int primary key auto_increment, user_id int, chat_id int, foreign key (user_id) references users(id), foreign key (chat_id) references chats(id) ); select ch1.chat_id from chat_user ch1 join chat_user ch2 using (chat_id) where ch1.user_id = 1 and ch2.user_id = 2;
Stuck with a problem? Got Error? Ask ChatGPT!
Copy Clear