INSERT...ON DUPLICATE
Posted: Thu Aug 30, 2007 11:05 am
Hey dudes,
please help me with this situation:
I have 4 columns (mode, position, pageid, counter) and I need to have unique combinations of columns except counter. If there is situation I already have any combination then counter + 1. I wanted to use:
It works in SQL command line, but it's strange and PHP doesn't work with it at all.
Thanks.
please help me with this situation:
I have 4 columns (mode, position, pageid, counter) and I need to have unique combinations of columns except counter. If there is situation I already have any combination then counter + 1. I wanted to use:
Code: Select all
INSERT INTO ana_produkt (mode,position,pid) VALUES ('$mode','$position','$pid') ON DUPLICATE KEY UPDATE counter=counter; UPDATE ana_produkt SET counter=counter+1 WHERE mode='$mode' AND position='$position' AND pid='$pid';
Thanks.