SQLize Online / PHPize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
-- Hint: use Ctrl+Enter for SQL autocomplete create table "item" ( itemid char(3), price int, time int ); insert into "item" values ('RBK', 92, 1546408800), ('LBV', 51, 1546408800), ('ZBT', 49, 1546408800), ('GLS', 22, 1546408800), ('DBC', 17, 1546408800), ('RBK', 91, 1546495200), ('LBV', 55, 1546495200), ('ZBT', 51, 1546495200), ('GLS', 24, 1546495200), ('DBC', 28, 1546581600), ('RBK', 108, 1546581600), ('LBV', 46, 1546581600), ('ZBT', 49, 1546581600), ('GLS', 21, 1546581600), ('DBC', 107, 1546581600); create table "user" ( userid int, itemid char(3), timecreated int, quantitty int, firstprice int, currentprice int, difference int ); insert into "user" (userid, itemid, timecreated, quantitty) values (1, 'RBK', 1546408800, 20 ), (2, 'RBK', 1546408800, 15 ), (3, 'RBK', 1546408800, 35 ), (3, 'GLS', 1546408800, 101 ), (3, 'DBC', 1546495200, 140 ), (1, 'RBV', 1546495200, 141 ), (2, 'RBK', 1546495200, 25 ), (2, 'RBV', 1546581600, 31 ); update "user" set firstprice = ( select price from "item" i where i.itemid = "user".itemid and i.time >= "user".timecreated order by i.time limit 1 ); select * from "user";
Stuck with a problem? Got Error? Ask ChatGPT!
Copy Clear