Re: [sqlite] How to check whether a table is empty or not in sqlite.
On 2/13/2012 11:20 AM, Kit wrote: 2012/2/13 Igor Tandetnik: bhaskarReddy wrote: How to check whether a table is empty or not. If a table is empty, i want to do some logic. If not another logic. select exists (select 1 from MyTable); SELECT exists(SELECT 1 FROM MyTable LIMIT 1); exists() predicate is smart enough to stop as soon as the first row is retrieved. LIMIT 1 clause is redundant, though harmless. -- Igor Tandetnik ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] How to check whether a table is empty or not in sqlite.
2012/2/13 Igor Tandetnik: > bhaskarReddy wrote: >> How to check whether a table is empty or not. If a table is empty, i >> want to do some logic. If not another logic. > > select exists (select 1 from MyTable); SELECT exists(SELECT 1 FROM MyTable LIMIT 1); -- Kit ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] How to check whether a table is empty or not in sqlite.
On Mon, Feb 13, 2012 at 03:48:24PM +, Simon Slavin scratched on the wall: > > On 13 Feb 2012, at 1:02pm, Igor Tandetnik wrote: > > > bhaskarReddywrote: > >> How to check whether a table is empty or not. If a table is empty, i > >> want to do some logic. If not another logic. > > > > select exists (select 1 from MyTable); > SELECT COUNT(*) from MyTable For a large table, that might take some time. -j -- Jay A. Kreibich < J A Y @ K R E I B I.C H > "Intelligence is like underwear: it is important that you have it, but showing it to the wrong people has the tendency to make them feel uncomfortable." -- Angela Johnson ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] How to check whether a table is empty or not in sqlite.
On 13 Feb 2012, at 1:02pm, Igor Tandetnik wrote: > bhaskarReddywrote: >> How to check whether a table is empty or not. If a table is empty, i >> want to do some logic. If not another logic. > > select exists (select 1 from MyTable); Or SELECT COUNT(*) from MyTable which will give you 0 if the table is empty, and some other integer otherwise. Simon. ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] How to check whether a table is empty or not in sqlite.
bhaskarReddywrote: >How to check whether a table is empty or not. If a table is empty, i > want to do some logic. If not another logic. select exists (select 1 from MyTable); -- Igor Tandetnik ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
[sqlite] How to check whether a table is empty or not in sqlite.
HI Friends, How to check whether a table is empty or not. If a table is empty, i want to do some logic. If not another logic. Can any one tell me how to check if table in a data base is empty or not, using sqlite3. Regards, Bhaskar. -- View this message in context: http://old.nabble.com/How-to-check-whether-a-table-is-empty-or-not-in-sqlite.-tp33314679p33314679.html Sent from the SQLite mailing list archive at Nabble.com. ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users