O'Reilly logo

Mastering PhoneGap Mobile Application Development by Kerri Shotts

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Inserting data and binding values

In SQL, we store data using two statements (usually): INSERT INTO and UPDATE. The first is used when you're adding data to a table, and the second is used to update data that already exists. There's also a variant that permits the merging of data: data that doesn't exist is added, and data that does exist is updated. Various SQL database servers do this differently, but SQLite uses INSERT OR REPLACE INTO.

Note

The snippets in this section are located at snippets/08/ex4-insert-data/ in the code package of this book. When using the interactive snippet playground, select 8: Web SQL Database and Example 4.

The INSERT INTO statement looks as follows:

INSERT [OR REPLACE] INTO tableName ( fieldName [, ...] ) VALUES ( values ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required