Re: (if !update then insert) sequence - result Duplicate key :(

2004-10-01 Thread Keith Ivey
Laercio Xisto Braga Cavalcanti wrote: When you use the replace command if the row does not exist it is inserted. MySQL Reference Manual: Section 14.1.6 REPLACE works exactly like INSERT, except that if an old record in the table has the same value as a new record for a PRIMARY KEY or a UNIQUE index

RE: (if !update then insert) sequence - result Duplicate key :(

2004-10-01 Thread Laercio Xisto Braga Cavalcanti
before the new record is inserted Regards, Laercio. -Original Message- From: news [mailto:[EMAIL PROTECTED] On Behalf Of Harald Fuchs Sent: quinta-feira, 30 de setembro de 2004 11:39 To: [EMAIL PROTECTED] Subject: Re: (if !update then insert) sequence - result Duplicate key :( In

Re: (if !update then insert) sequence - result Duplicate key :(

2004-09-30 Thread Harald Fuchs
In article <[EMAIL PROTECTED]>, "Laercio Xisto Braga Cavalcanti" <[EMAIL PROTECTED]> writes: > Hi, > To solve this you can use the REPLACE command. The problem is that Aleksandr wants to increment a counter, not set it to some fixed value. How could you use REPLACE for that? -- MySQL General

RE: (if !update then insert) sequence - result Duplicate key :(

2004-09-30 Thread Laercio Xisto Braga Cavalcanti
Hi, To solve this you can use the REPLACE command. Regards, Laercio. -Original Message- From: news [mailto:[EMAIL PROTECTED] On Behalf Of Harald Fuchs Sent: quinta-feira, 30 de setembro de 2004 08:25 To: [EMAIL PROTECTED] Subject: Re: (if !update then insert) sequence - result

Re: (if !update then insert) sequence - result Duplicate key :(

2004-09-30 Thread Harald Fuchs
In article <[EMAIL PROTECTED]>, "Aleksandr V. Dyomin" <[EMAIL PROTECTED]> writes: > $key='somekeyvalue'; > dbquery("update sometable set count=count+1 where keyfield='$key'"); > if(mysql_affected_rows()<1) > dbquery('insert into sometable set keyfield='$key', count=1'); > --- > First questi

Re: (if !update then insert) sequence - result Duplicate key :(

2004-09-29 Thread Aleksander V. Dyomin
В Чтв, 30.09.2004, в 00:37, [EMAIL PROTECTED] пишет: > I have another technique for this kind of data merge that speeds things up > (a lot!) but it requires a third table to make it work > > Please post the results of SHOW CREATE TABLE for both the source data > table and the destination data ta

Re: (if !update then insert) sequence - result Duplicate key :(

2004-09-29 Thread Aleksander V. Dyomin
В Чтв, 30.09.2004, в 00:50, Keith Ivey пишет: > Aleksandr V. Dyomin wrote: > > >$key='somekeyvalue'; > >dbquery("update sometable set count=count+1 where keyfield='$key'"); > >if(mysql_affected_rows()<1) > > dbquery('insert into sometable set keyfield='$key', count=1'); > > > > Another possib

Re: (if !update then insert) sequence - result Duplicate key :(

2004-09-29 Thread Keith Ivey
Aleksandr V. Dyomin wrote: $key='somekeyvalue'; dbquery("update sometable set count=count+1 where keyfield='$key'"); if(mysql_affected_rows()<1) dbquery('insert into sometable set keyfield='$key', count=1'); Another possibility would be INSERT IGNORE INTO sometable SET keyfield = '$key',

Re: (if !update then insert) sequence - result Duplicate key :(

2004-09-29 Thread SGreen
I have another technique for this kind of data merge that speeds things up (a lot!) but it requires a third table to make it work Please post the results of SHOW CREATE TABLE for both the source data table and the destination data table and I will show you how it works. Thanks, Shawn Green Dat

Re: (if !update then insert) sequence - result Duplicate key :(

2004-09-29 Thread Aleksander V. Dyomin
Thanx for reply! В Срд, 29.09.2004, в 23:21, Jim Grill пишет: > > $key='somekeyvalue'; > > dbquery("update sometable set count=count+1 where keyfield='$key'"); > > if(mysql_affected_rows()<1) > > dbquery('insert into sometable set keyfield='$key', count=1'); > > --- > > > > First question: this is

Re: (if !update then insert) sequence - result Duplicate key :(

2004-09-29 Thread Jim Grill
> Hi! > > Sorry for my ugly English. > I use mysql in my PHP script(for calculating INs and OUTs from site). > And I meet some strange thing there. > > Example goal: store statistics for clicks on some links. > I use next algorithm: > > --- > $key='somekeyvalue'; > dbquery("update sometable set cou

(if !update then insert) sequence - result Duplicate key :(

2004-09-29 Thread Aleksandr V. Dyomin
Hi! Sorry for my ugly English. I use mysql in my PHP script(for calculating INs and OUTs from site). And I meet some strange thing there. Example goal: store statistics for clicks on some links. I use next algorithm: --- $key='somekeyvalue'; dbquery("update sometable set count=count+1 where keyf