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 users ( id int, name varchar(64), flag1 tinyint, flag2 tinyint, flag3 tinyint, flag4 tinyint ); insert into users values (1, 'user1', 1, 0, 1, 0), (2, 'user2', 0, 1, 0, 0), (3, 'user3', 1, 1, 0, 1), (4, 'user4', 1, 0, 0, 0); select * from users; select * from users order by ((flag1=1)*1 + (flag2=0)*1 + (flag3=1)*1 +(flag4=0)*1) desc

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

Copy Clear