I am developing an app in Android/Phonegap using Javascript. I have tried the insert query in sqlite with Not Exists.
Here is my code:
var name='aaaaa';
tx.executeSql('INSERT INTO Demo(Id,Name) SELECT ('1','+name+') WHERE
NOT EXISTS (SELECT 1 FROM Demo WHERE Id='1')');
When I give one column name it’s working fine. But when I give two or more columns (eg: id, name, address), it’s not working. Please kindly guide me. Thanks in advance.
When you give more columns you also need to give more values. The values come from your Select clause in the SQL statement. You need the same number of values in the Select as columns in your Insert:
If this doesn’t solve your problem please post a SQL that is not working.