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 t ( article_id int, id int ); insert into t values (50, 1), (50, 2), (50, 3); SELECT if(id = max, min, id) as next FROM t, (select max(id) as max, min(id) as min from t where article_id = 50) as m WHERE article_id = 50 AND id > 2 LIMIT 1;

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

Copy Clear