MySQL has a neat feature, but to be used with care:
REPLACE INTO table(id, field1, field2, ...) VALUES(1, f1, f2, ...)
This needs id to be primary key column. If MySQL finds the record with id=1 it will do two things:
1. DELETE the row
2. INSERT the row with the same id.
What to be noted - of you don't specify ALL fields then you will lose existing fields in that row. In short, this mean that this command does not update listed fields, rather it will delete the row and insert fields which have been specified in the command.
__________________
onPHP5.com -
PHP5: Articles, News, Tutorials, Interviews, Software and more