We Recommend

SQL Cookbook SQL Cookbook
Written in O'Reilly's popular Problem/Solution/Discussion style, the SQL Cookbook is sure to please. Anthony's credo is: "When it comes down to it, we all go to work, we all have bills to pay, and we all want to go home at a reasonable time and enjoy what's still available of our days." The SQL Cookbook moves quickly from problem to solution, saving you time each step of the way.


Posted By

drk on 03/30/08


Tagged

mysql select duplicate update


Versions (?)


Who likes this?

1 person has marked this snippet as a favorite

heinz1959


UPDATE, falls Eintrag schon vorhanden, sonst INSERT


Published in: SQL 


URL: http://betamode.de/2007/08/23/mysql-insert-on-duplicate-key-update/

Wenn ein INSERT einen doppelten Wert erzeugen würde, wird das UPDATE ausgeführt.

  1. mysql_query(INSERT INTO sample VALUES( $id, ‘$name’, ‘$tag’) ON DUPLICATE KEY UPDATE name=’$name’,tag=’$tag’”);

Report this snippet 

You need to login to post a comment.