Am working in HTML5 + PhoneGap Applications with SQlite
For updating the table in SQlite ; am using REPLACE INTO method.
Here is example code ; : http://www.sqlfiddle.com/#!7/ccc33/2
Schema
CREATE TABLE mytable (
id integer primary key autoincrement,
name VARCHAR(10),
date DATE,
job VARCHAR(16),
hours VARCHAR(16)
);
CREATE UNIQUE INDEX myindex ON mytable(NAME);
Here NAME is the UNIQUE INDEX vale.
Query
REPLACE INTO mytable (NAME, DATE, JOB, HOURS)
VALUES ('BOB', '12/01/01', 'PM','20');
REPLACE INTO mytable (NAME, DATE, JOB, HOURS)
VALUES ('BOB', '12/01/01', 'PM','32');
REPLACE INTO mytable (NAME, DATE, JOB, HOURS)
VALUES ('BOB', '14/01/01', 'PM','35');
REPLACE INTO mytable (NAME, DATE, JOB, HOURS)
VALUES ('BOBg', '12/01/01', 'PM','350');
SELECT * FROM mytable;
But when Run the Query ; i seen that the primary key id is incremented . But my need its only update when NAME is same.
Is there any solution for this? Please help!