On Thu, Dec 6, 2012 at 6:49 PM, Staffan Tylen <staffan.ty...@gmail.com> wrote:
> SELECT CASE WHEN EXISTS (...) END
>
> On Thu, Dec 6, 2012 at 5:47 PM, Durga D <durga.d...@gmail.com> wrote:
>
>> I have situation in which I want to read particular record if table exists.
>> Based on that record information, I have to execute some logic on other
>> tables of the same database. If record doesn't exist I need to create new
>> table.


SELECT * FROM ATable WHERE EXISTS (SELECT * FROM sqlite_master where
type = 'table' and name = '<YourTableName>')

Can also make it correlated if the name of the table whose existence
you are checking depends on the value of a column in each record of
ATable:

SELECT * FROM ATable WHERE EXISTS (SELECT * FROM sqlite_master where
type = 'table' and name = ATable.TableName)
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to