Re: UPDATE instead of INSERT INTO
| From: | Ron Piggott | Date: | Sat, 05 Sep 2009 23:40:03 +0000 |
| Subject: | Re: UPDATE instead of INSERT INTO | ||
| References: | 1 2 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-46472@lists.php.net to get a copy of this message | ||
Thanks
----- Original Message ----- From: "Waynn Lue" <waynnlue@gmail.com>
To: "Ron Piggott" <ron.php@actsministries.org>; <php-db@lists.php.net>
Sent: Saturday, September 05, 2009 4:45 PM
Subject: Re: [PHP-DB] UPDATE instead of INSERT INTO
INSERT INTO ON DUPLICATE KEY UPDATE is what you're looking for. On 9/5/09, Ron Piggott <ron.php@actsministries.org> wrote:-------------------------------------------------------------------------------- No virus found in this incoming message. Checked by AVG - www.avg.com Version: 8.5.409 / Virus Database: 270.13.78/2347 - Release Date: 09/05/09 05:51:00I made an application which lets users rate web site content. At the heart of the application is this mySQL query: INSERT INTOratings(reference,content_type,content_reference,language,ip_address,rating_timestamp,rating) VALUES ( NULL , '$content_type','$content_reference' , '$language', '$ip_address', NOW( ) , '$user_rating' ); I am wondering if there is a way to check if the user has already voted (IE If there is already a matching record with the same content_type, content_reference, language, ip_address values) so all that happens is an UPDATE to the rating field? Ron