[prog] mysql insert/update/replace

Wolf Rising wolfrising at gmail.com
Mon Jul 25 11:12:10 EST 2005


Hi,

I'm trying to have a form automatically update(overwrite) a previous
entry if needed, I have a select statement to check if any entries
already exists:

select * from status where date = now();

if this returns nothing I do an insert:

$query = "insert into status values ('1', now(), '$one'), ('2', now(),
'$two'), ('3', now(),'$three'), ('4', now(),'$four');";

there are four rows each time that need to be effected. If the
entries already exist I want to be able to update/replace the
current entries with new ones. I had found on duplicate key but
it doesn't work with the older version of mysql that is installed.

Is it possible using either update or replace to effect all
four rows the way it's possible to insert the information for
all four rows at once?

Thanks


More information about the Programming mailing list