Re: [sqlite] Expressions

2006-03-03 Thread Christian Smith
On Fri, 3 Mar 2006, Roger wrote:

>How do i use expressions in SQLite.
>
>For instance, i want to be able to use Case when i execute my sql so
>that i have a row which looks up a value rather than querying it from a
>table
>


If you just want to use CASE to do the lookup with hard coded values, then
use something like:
  SELECT CASE col
   WHEN 'foo' THEN 'foo value'
   WHEN 'bar' THEN 'bar value'
   ELSE 'default value'
 END FROM atable;

Have as many WHEN clauses as you like, and leave the ELSE off which
defaults to NULL, I believe.

Note, however, that lots of WHEN clauses will take a long time
(relatively) to parse, and result in a large compiled statement. You might
well be advised to pre-compile such a statement. Note also, that the
generated compiled statement does a linear search through the WHEN cases,
and will do this search for each and every row, and so this could get
quite expensive, as well as being static.

What specifically are you trying to achieve?

Christian

-- 
/"\
\ /ASCII RIBBON CAMPAIGN - AGAINST HTML MAIL
 X   - AGAINST MS ATTACHMENTS
/ \


[sqlite] Expressions

2006-03-03 Thread Roger
How do i use expressions in SQLite.

For instance, i want to be able to use Case when i execute my sql so
that i have a row which looks up a value rather than querying it from a
table