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, name varchar(64), u_status int ); CREATE TABLE country ( id int, country varchar(64) ); INSERT INTO users VALUES (1, 'Ivan', 1), (2, 'Natasha', 1), (3, 'Putin Huilo', 1); CREATE TABLE user_to_country ( user_id int, country_id int ); INSERT INTO country VALUES (1, 'Russia'), (2, 'Germany'), (3, 'Poland'), (4, 'Italy'), (5, 'Austria'); INSERT INTO user_to_country VALUES (1, 2), (1, 1), (1, 5), (1, 4), (2, 2), (2, 2), (2, 2), (3, 3), (3, 4); select users.id, users.name, group_concat(country.country) as visited from users left join user_to_country on user_to_country.user_id = users.id left join country on user_to_country.country_id = country.id where u_status = 1 group by users.id, users.name;

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

Copy Clear