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, product_id int, name varchar(64), variant varchar(64), price decimal(9,2) ); insert into products (product_id, name, variant, price) select coalesce ( min(case when name = 'мышь' then product_id end ), coalesce(min(product_id), 0) + 1 ) product_id ,'мышь', 'красная', 150 from products; insert into products (product_id, name, variant, price) select coalesce ( min(case when name = 'мышь' then product_id end ), coalesce(min(product_id), 0) + 1 ) product_id ,'мышь', 'синяя', 150 from products; insert into products (product_id, name, variant, price) select coalesce ( min(case when name = 'мышь' then product_id end ), coalesce(min(product_id), 0) + 1 ) product_id ,'мышь', 'белая', 150 from products; insert into products (product_id, name, variant, price) select coalesce ( min(case when name = 'белка' then product_id end ), coalesce(min(product_id), 0) + 1 ) product_id, 'белка', 'белая', 150 from products; insert into products (product_id, name, variant, price) select coalesce ( min(case when name = 'белка' then product_id end ), coalesce(min(product_id), 0) + 1 ) product_id, 'белка', 'красная', 150 from products; /*1 0 мышь красная 150 2 0 мышь синяя 150 3 0 мышь белая 150*/ select * from products;

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

Copy Clear