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 departments( department_id serial primary key, department_name varchar(100) not null ); create table employees( id serial primary key, name varchar(100) not null, department_id int, constraint fk_department foreign key (department_id) references departments (department_id) ); insert into departments (department_name) values ('sales'), ('marketing'); insert into employees (name, department_id) values ('Jane', 1), ('Bob', 2), ('Maria', null); --select employees.name, departments.department_name from employees --left join departments on departments.department_id = employees.id; select employees.name from employees where employees.department_id in ( select department_id from departments )

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

Copy Clear