mysql - A error while using case next to order by -


the code supposed give me table ordered after if value 'isonline' == 1 'onlinetime', if 'isonline' == 0 onlinetime + current milliseconds since midnight, january 1, 1970 utc (isonline tinyint, onlinetime bigint)

select * onlinecountertable  order      case `isonline`         when 0 `onlinetime`         when 1 (onlinetime + (round(unix_timestamp(curtime(4)) * 1000))         else `onlinetime`      end     desc limit 30  

but if use query above, gives me error:

#1064 - have error in sql syntax; check manual corresponds mysql server version right syntax use near 'else -1     end)     desc limit 30 limit 0, 25' @ line 6 

replace this

    when 1 (onlinetime + (round(unix_timestamp(curtime(4)) * 1000)) 

by this

    when 1 (onlinetime + round(unix_timestamp(curtime(4)) * 1000)) 

cheers ;-)


Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -