mysql - How does the ORDER BY CASE Clause Work in the following Code? -


how part of code work?

order    case when subject in ('chemistry','physics') 1 else 0 end,    subject,    winner; 

first checks if subjet chemistry or physics. if sorting score 1.

if subject not contain of "chemistry" or "physics" score 0.

after sorts results score results contains chemistry or physics come first after dont contain.


Comments

Popular posts from this blog

c - zlib and gdi32 with OpenSSL? -

java - inputmismatch exception -

ios - Align baselines with characters in large line heights with Text Kit -