Your skill will accomplish what the force of many cannot |
|
PerlMonks |
mysql insert/updateby rsiedl (Friar) |
on May 31, 2004 at 09:57 UTC ( [id://357759]=perlquestion: print w/replies, xml ) | Need Help?? |
rsiedl has asked for the wisdom of the Perl Monks concerning the following question:
This is more of a MySQL question, but I am sure someone out there will know an answer. Is there and easy way to insert/update a record in a mysql table depending upon whether or not the record exists? i.e. if ($id exists in table) { update field=value where id=$id } else { insert into table id=$id, field=$value } Hope that makes sense :) At the moment I am doing a select and then using a perl if statement to determine if it should update or insert. But I am sure there must be an easier way for such a common thing. Any help would be appreciated. Cheers, Reagen
Back to
Seekers of Perl Wisdom
|
|