On Tue, Dec 08, 2009 at 10:23:46PM +0000, Simon Slavin scratched on the wall:
> My Google-fu appears to be weak.  SQLite apparently supports a
> CASE ... WHEN construction.  Where on www.sqlite.org is the
> meaning defined ?  I can see CASE mentioned in diagrams on

  I'm not sure it is.  I thought it was a fairly standard SQL expression.

> but I don't understand the use of the optional expression immediately
> after the CASE token.

  With the optional expression, the "when" sub-expressions become an
  "equal to" condition, kind of like a "select" in C/C++:

sqlite> SELECT   CASE 3   WHEN 4 THEN 'four' WHEN 3 THEN 'three' END;
three

  Without the optional expression, the "when" sub-expressions become an
  "is true" condition, kind of like a chain of if/else-if/else-if
  expressions in C/C++:

sqlite> SELECT   CASE    WHEN NULL THEN 'null' WHEN 0 THEN 'zero'
   ...>   WHEN 1 THEN 'one' WHEN 2 THEN 'two' END;
one


   -j

-- 
Jay A. Kreibich < J A Y  @  K R E I B I.C H >

"Our opponent is an alien starship packed with atomic bombs.  We have
 a protractor."   "I'll go home and see if I can scrounge up a ruler
 and a piece of string."  --from Anathem by Neal Stephenson
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to