On Sat, 05 Mar 2016 13:24 +0000, Tim Streater <tim at clothears.org.uk> wrote:
>
> In my case I want to know whether at least one row exists that has a certain
> column which has a given value. At the minute I do this:
>
>   select count(*) from mytable where status=1 limit 1;
>

SELECT 1 FROM mytable WHERE status=1 LIMIT 1;

Then if sqlite3_step() returns SQLITE_ROW you know that a row with
status=1 exists, but if sqlite3_step() returns SQLITE_DONE, you know
that no such row exists.

-- 
D. Richard Hipp
drh at sqlite.org

Reply via email to