Q:

Insert or ignore a record

I have a table
CREATE TABLE "myTable" (
    "id" INTEGER NOT NULL, 
    "name" VARCHAR,
    PRIMARY KEY ("id")
)

and let's say it has 1 record 
1 - James

I want to insert a new record. If it doesn't exist, insert it. If it does, do nothing.
I am not sure if the below query, is the right way to do this:
INSERT or IGNORE INTO myTable(id, name) VALUES(1, "Tom");

I tried it and I didn't get any error..

A:

Your statement is fine for what you want to do.  However, you don't need to supply a value for id in SQLite.  You can just do:
INSERT INTO myTable(name)
    VALUES('Tom');

This will auto-increment the id, so you don't have to worry about duplicates.

