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

SQLize Online / PHPize Online  /  SQLtest Online

A A A
Login    Share code      Blog   FAQ

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

Copy Format Clear
CREATE TABLE `groups` ( `id` INT PRIMARY KEY, `name` VARCHAR(255) ); CREATE TABLE `users` ( `id` INT PRIMARY KEY, `group_id` INT, FOREIGN KEY (`group_id`) REFERENCES `groups`(`id`) ); CREATE TABLE `appointments` ( `id` INT PRIMARY KEY, `user_id` INT, FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ); SELECT a.* FROM appointments a JOIN users u ON a.user_id = u.id WHERE u.group_id = ( SELECT group_id FROM users WHERE users.id = '<User ID what you need>' -- Replace with an actual user ID );

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

Copy Clear