Jean-Christophe Deschamps wrote:
>> Andrea Galeazzi wrote:
>>> I've got a table T made up of only two fields: INT id (PRIMARY KEY) and
>>> INT length.
>>> I need a statement in order to yield 0 when the key doesn't exist.
>> 
>> Well, "select 0;" fits your spec (you never said what should be
>> returned when the key does exist). I would hazard a guess that you
>> meant something like this:
>> 
>> select coalesce((select length from T where id=?), 0);
> 
> Sorry to ask but isn't the following exactly the same, but even easier
> to read?
> 
> select exists(select rowid from T where id=?);

Yours returns 1 or 0. Mine returns length if found, otherwise 0.

Igor Tandetnik

_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to