SQLize Online / PHPize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
-- Hint: use Ctrl+Enter for SQL autocomplete create table table1 ( name varchar(32) primary key, total int, price int ); insert into table1 values ('A', NULL, 5), ('B', NULL, 5), ('C', NULL, 5); create table table2 ( total2 int ); insert into table2 values (15), (1), (5); UPDATE table1 JOIN ( SELECT name, total2, ROW_NUMBER() OVER () AS rn FROM table1 JOIN table2 ORDER BY name ) AS t ON table1.name = t.name SET table1.total = t.total2; SELECT * FROM table1;

Stuck with a problem? Got Error? Ask ChatGPT!

Copy Clear