On 15 Sep 2015, at 5:01pm, Nicolas J?ger <jagernicolas at legtux.org> wrote:
> I also would like to know how can I check if an entry exists,(or not > exists), in a table. Like, > > IF (exists) THEN (doSomething) END Here's another alternative to add to those in Ryan's excellent post. With your schema > create table Tags > ( > id integer primary key, > name text collate nocase unique, > count integer not null > ); You can do things like SELECT total(count) FROM Tags WHERE id=234; SELECT total(count) FROM Tags WHERE name='biology'; You will definitely get a reply from this since 'total()' returns 0.0 even if there are no rows which satisfy the WHERE clause. So you can submit this query and know that there is definitely an answer which is definitely a floating point value. And then in your programming language you can do your equivalent of IF (theanswer) > 0.0 THEN (doSomething) END Warning: although SQLite also has the function sum() it does not produce the same result to total() when no lines satisfy the WHERE clause. Sorting out the possibilities is more complicated. Simon.