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 products ( id int primary key auto_increment, name text, manufacturer varchar(64) ); insert into products (name, manufacturer) values ('Носки', 'Фабрика Восход'), ('Трусы', 'Фабрика Восход') , ('Трусы', 'Фабрика Заря'); create table spent ( product_id int references products(id), created_at timestamp default current_timestamp ); insert into spent (product_id) values (1); select products.*, case when bad_manufacturers.manufacturer is null then 'Хороший производитель' else 'Бракодел' end manufacturer_rate from products left join ( select distinct manufacturer from spent s join products p on p.id = s.product_id ) bad_manufacturers using (manufacturer)

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

Copy Clear