Re: If Exists update else insert

2004-02-18 Thread Victoria Reznichenko
"Juan E Suris" <[EMAIL PROTECTED]> wrote: > I need to do something similar to replace, but can't figure out how to do it. > > Here's my table: > user varchar(15) PRI > cnt int(11) > > I want to increment cnt for user if it exists, else insert a row with cnt=1. I tried > the following, but mysql

If Exists update else insert

2004-02-18 Thread Juan E Suris
I need to do something similar to replace, but can't figure out how to do it. Here's my table: user varchar(15) PRI cnt int(11) I want to increment cnt for user if it exists, else insert a row with cnt=1. I tried the following, but mysql complains that I can't use the same table in the update

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",

Re: SV: If exists UPDATE else INSERT

2001-01-26 Thread Gerald L. Clark
ert it if you get an error? > > -Opprinnelig melding- > Fra: Artem Koutchine [mailto:[EMAIL PROTECTED]] > Sendt: 26. januar 2001 19:02 > Til: [EMAIL PROTECTED]; [EMAIL PROTECTED] > Emne: Re: If exists UPDATE else INSERT > > I've seen something about this in t

SV: If exists UPDATE else INSERT

2001-01-26 Thread Pål Wester
Why not do an update regardless if the record exist or not, then insert it if you get an error? -Opprinnelig melding- Fra: Artem Koutchine [mailto:[EMAIL PROTECTED]] Sendt: 26. januar 2001 19:02 Til: [EMAIL PROTECTED]; [EMAIL PROTECTED] Emne: Re: If exists UPDATE else INSERT I've

Re: If exists UPDATE else INSERT

2001-01-26 Thread Artem Koutchine
CTED]> To: <[EMAIL PROTECTED]> Sent: Friday, January 26, 2001 7:34 PM Subject: If exists UPDATE else INSERT > I'm have a lot of queries where i have to check if a record exists > and if it does, increment a counter in it (most of the time). If it doesn't > exist I insert

If exists UPDATE else INSERT

2001-01-26 Thread Jan Willamowius
I'm have a lot of queries where i have to check if a record exists and if it does, increment a counter in it (most of the time). If it doesn't exist I insert a new record with counter=1 (this case is rare). Right now I do a select form Perl and then do one or the other. To speed things up I could