Re: query: if exists UPDATE else INSERT?

2003-07-14 Thread Sergei Golubchik
Hi! On Jul 13, Alexander Newald wrote: > Hello, > > I have a table with id (char(8)) and value (int(8)) > > To make my problem clear: > > There is no set with id = "20030713" > insert into table values ("20030713","10"); > > The next set is ("20030713","20") but as a set with 20030713 is > alr

Re: query: if exists UPDATE else INSERT?

2003-07-13 Thread Paul Chvostek
On Sun, Jul 13, 2003 at 09:52:10AM -0400, Paul Chvostek wrote: ... > $q = "UPDATE table SET value=value+$value WHERE id='$id';"; > $q .= "INSERT INTO table (id,value) VALUES ('$id',$value)"; > @mysql_query($q); Woop, I forgot this was the mysql list, not a php- list. ;-) The basic thing

Re: query: if exists UPDATE else INSERT?

2003-07-13 Thread Paul Chvostek
On Sun, Jul 13, 2003 at 11:50:40AM +0200, Alexander Newald wrote: > > I'm looking for a solution to write a sql query that inserts a set of data if the > data id is not present and otherwise update the set. We covered some of this in a thread named "Bulk loading data" that started on July 8th.

Re: query: if exists UPDATE else INSERT?

2003-07-13 Thread Veysel Harun Sahin
Try this: set @w = 0; select @w := value from table where id = "20030713"; delete from table where id = "20030713"; insert into table values ("20030713", @w + 20); [EMAIL PROTECTED] wrote: Hello, I'm looking for a solution to write a sql query that inserts a set of data if the data id is not

query: if exists UPDATE else INSERT?

2003-07-13 Thread Alexander Newald
Hello, I'm looking for a solution to write a sql query that inserts a set of data if the data id is not present and otherwise update the set. I have a table with id (char(8)) and value (int(8)) To make my problem clear: There is no set with id = "20030713" insert into table values ("20030713",