Increase for 1 using REPLACE function

I have to increase 'no_of_visits' for 1.
Using UPDATE function is easy:

update visits set no_of_visits=no_of_visits+1 where visitor_id=123

but, how it should be (if possible at all) if I want to use REPLACE
function?

I tried something similar

replace into visitors values ($visitor_id, (no_of_visits+1))

but it doesn't work?!?

Thanks.

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?unsub=gcdmg-mysql-2 [at] m.gmane.org
afan [ Fr, 18 März 2011 23:24 ] [ ID #2056803 ]

Re: Increase for 1 using REPLACE function

>>>> 2011/03/18 17:24 -0500, Afan Pasalic >>>>
I have to increase 'no_of_visits' for 1.
Using UPDATE function is easy:

update visits set no_of_visits=no_of_visits+1 where visitor_id=123

but, how it should be (if possible at all) if I want to use REPLACE
function?

I tried something similar

replace into visitors values ($visitor_id, (no_of_visits+1))

but it doesn't work?!?
<<<<<<<<
Of course; the MySQL "REPLACE" command is not meant for that. It is simply the same as "INSERT" unless the table has a key, also given in the transaction. "UPDATE" is the right command for this.


--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?unsub=gcdmg-mysql-2 [at] m.gmane.org
(Sándor Halász) hsv [ Fr, 18 März 2011 23:53 ] [ ID #2056851 ]
Datenbanken » gmane.comp.db.mysql.general » Increase for 1 using REPLACE function

Vorheriges Thema: mysql using aio/raw device on linux
Nächstes Thema: Surge 2011 Conference CFP