Re: [sqlite] one liner for insert or update ?

2009-09-14 Thread yogibabu
UIT DEVELOPMENT wrote: Are you wanting something like this: INSERT INTO 'mytable' (key, 'visitorcount', 'visitdate') VALUES (123456789, 1, NOW()) ON DUPLICATE KEY UPDATE 'visitorcount' = 'visitorcount' + 1 the key statement being: ON DUPLICATE KEY UPDATE not tested but it seems

Re: [sqlite] one liner for insert or update ?

2009-09-14 Thread Jean-Christophe Deschamps
I tried twice to post it but it seems it didn't find its way to the list. Sorry if ever it gets dupped. Hi, insert or replace deletes all rows that weren't specified in the query Do you have a short example where INSERT OR REPLACE INTO ... can be shown to actually _delete_ rows? Which query

Re: [sqlite] one liner for insert or update ?

2009-09-14 Thread Jean-Christophe Deschamps
At 01:29 14/09/2009, you wrote: ´¯¯¯ CREATE TABLE table1( id INTEGER PRIMARY KEY ON CONFLICT REPLACE, field1 TEXT ); but I think that the table has to already have been created this way. `--- Yes from what he said, I also believe this is the right and simplest way.

Re: [sqlite] one liner for insert or update ?

2009-09-14 Thread yogibabu
Jean-Christophe Deschamps wrote: Do you have a short example where INSERT OR REPLACE INTO ... can be shown to actually _delete_ rows? Which query are you refering to? sorry, i meant columns not rows, whet i do insert command, specifying existing id and only some of the columns then the

Re: [sqlite] one liner for insert or update ?

2009-09-14 Thread Jean-Christophe Deschamps
At 10:25 14/09/2009, you wrote: ´¯¯¯ sorry, i meant columns not rows, whet i do insert command, specifying existing id and only some of the columns then the rest of the columns are deleted on the other hand, UPDATE command won't allow me to insert a new row Then you can still do something along

Re: [sqlite] one liner for insert or update ?

2009-09-14 Thread Jay A. Kreibich
On Mon, Sep 14, 2009 at 01:25:29AM -0700, yogibabu scratched on the wall: Jean-Christophe Deschamps wrote: Do you have a short example where INSERT OR REPLACE INTO ... can be shown to actually _delete_ rows? Which query are you refering to? sorry, i meant columns not rows, whet

Re: [sqlite] one liner for insert or update ?

2009-09-13 Thread yogibabu
Doug-4 wrote: Wouldn't INSERT OR REPLACE do that for you? (which by the way, has to be one of the coolest features in SQLite of all!) http://www.sqlite.org/lang_insert.html insert or replace deletes all rows that weren't specified in the query, i don't know maybe in combination with

Re: [sqlite] one liner for insert or update ?

2009-09-13 Thread UIT DEVELOPMENT
Are you wanting something like this: INSERT INTO 'mytable' (key, 'visitorcount', 'visitdate') VALUES (123456789, 1, NOW()) ON DUPLICATE KEY UPDATE 'visitorcount' = 'visitorcount' + 1 the key statement being: ON DUPLICATE KEY UPDATE not tested but it seems like that is what you are looking for.

Re: [sqlite] one liner for insert or update ?

2009-09-13 Thread Jean-Christophe Deschamps
´¯¯¯ INSERT INTO 'mytable' (key, 'visitorcount', 'visitdate') VALUES (123456789, 1, NOW()) ON DUPLICATE KEY UPDATE 'visitorcount' = 'visitorcount' + 1 the key statement being: ON DUPLICATE KEY UPDATE not tested but it seems like that is what you are looking for. Its sometimes refered to

Re: [sqlite] one liner for insert or update ?

2009-09-13 Thread UIT DEVELOPMENT
Geez. I am sorry. You are correct. This is MySQL. Sorry about that and to the OP. (banging forehead with open faced palm of my hand!!!) Tony On Sun, Sep 13, 2009 at 6:56 PM, Jean-Christophe Deschamps j...@q-e-d.org wrote: ´¯¯¯ INSERT INTO 'mytable' (key, 'visitorcount', 'visitdate')

Re: [sqlite] one liner for insert or update ?

2009-09-13 Thread UIT DEVELOPMENT
I see this: CREATE TABLE table1( id INTEGER PRIMARY KEY ON CONFLICT REPLACE, field1 TEXT ); but I think that the table has to already have been created this way. I found that in the docs: http://sqlite.org/lang_conflict.html Would that help the OP? On Sun, Sep 13, 2009 at 6:56 PM,

[sqlite] one liner for insert or update ?

2009-09-12 Thread yogibabu
my dream is to be able do it like that: ?php $pdo = new PDO('sqlite:database.DB3'); $pdo-query(INSERT UPDATE table SET value1='somedata', value2=somedata, id=$getid ) ? when $getid contains data (a number of course) then an update is performed, otherwise if it is null then database engine

Re: [sqlite] one liner for insert or update ?

2009-09-12 Thread Doug
Of yogibabu Sent: Saturday, September 12, 2009 11:51 AM To: sqlite-users@sqlite.org Subject: [sqlite] one liner for insert or update ? my dream is to be able do it like that: ?php $pdo = new PDO('sqlite:database.DB3'); $pdo-query(INSERT UPDATE table SET value1='somedata', value2=somedata, id