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
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
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
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
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
В Чтв, 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
В Чтв, 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
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',
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
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
> 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
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
12 matches
Mail list logo