UPDATE or, if no record exists, INSERT


Fetching a set of records from a MYSQL data base in PHP.

This is the general format:

	INSERT INTO table (k,x,y) VALUES (1,2,3)
	ON DUPLICATE KEY UPDATE x=x+1;
  	

Assuming that k is the record key, if all data is to be created or replaced then this becomes:

	INSERT INTO table (k,x,y) VALUES (1,2,3)
	ON DUPLICATE KEY UPDATE x=2, y=3;