Re: [sqlite] if exist

2010-03-12 Thread Igor Tandetnik
Jean-Christophe Deschamps wrote: >> Yours returns 1 or 0. Mine returns length if found, otherwise 0. > > That's true but the subject title led me to believe that the OP > intended to have a 0 vs. nonzero return for not-exists vs exists condition. Perhaps. Nevertheless, the answer to your

Re: [sqlite] if exist

2010-03-12 Thread Jean-Christophe Deschamps
>Yours returns 1 or 0. Mine returns length if found, otherwise 0. That's true but the subject title led me to believe that the OP intended to have a 0 vs. nonzero return for not-exists vs exists condition. ___ sqlite-users mailing list

Re: [sqlite] if exist

2010-03-12 Thread Igor Tandetnik
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 >>

Re: [sqlite] if exist

2010-03-12 Thread Jean-Christophe Deschamps
>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

Re: [sqlite] if exist

2010-03-09 Thread Igor Tandetnik
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

Re: [sqlite] if exist

2010-03-09 Thread Andrea Galeazzi
It works fine! Thanks! Martin.Engelschalk ha scritto: > Hi, > > try this: > > select coalesce(min(length), 0) from t where id = ? > > Martin > > Andrea Galeazzi schrieb: > >> Hi All, >> I've got a table T made up of only two fields: INT id (PRIMARY KEY) and >> INT length. >> I need a

Re: [sqlite] if exist

2010-03-09 Thread Martin.Engelschalk
Hi, try this: select coalesce(min(length), 0) from t where id = ? Martin Andrea Galeazzi schrieb: > Hi All, > 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. At > this moment the query

[sqlite] if exist

2010-03-09 Thread Andrea Galeazzi
Hi All, 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. At this moment the query is too simple: SELECT length FROM T WHERE id = ? Any idea about it? Cheers