SQLize Online / PHPize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
CREATE TABLE test ( id INT NOT NULL PRIMARY KEY, col1 varchar(50), col2 varchar(50) ); insert into test values (13,"logo",null), (14,"logo",null), (15,null, "ulitsa"), (16,null,null), (17,null,null), (18,"logo",null), (19,"logo",null), (23,null, "ulitsa"); select max_col1, t1.col1, max_col2, t2.col2 from ( select max(if(col1 is null, 0, id)) max_col1, max(if(col2 is null, 0, id)) max_col2 from test) last_values join test t1 on t1.id = max_col1 join test t2 on t2.id = max_col2;
Stuck with a problem? Got Error? Ask ChatGPT!
Copy Clear