Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
I'm logging some HTML form data to MySQL, and need to either INSERT the row with that data if it is unique, or UPDATE the existing row if some of the data already exists in the database (these are URLs).
I can do the INSERT for every form submit, but I'm unclear how to check if the URL exists already, and if so, do an UPDATE, if not, do an INSERT.
Bonus points for those who can help me figure out how to make sure http://www.example.com/foo/bar.html and http://example.com/foo/bar.html are the same data, and only to INSERT/UPDATE it once.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: INSERT or UPDATE, but only when unique
by jZed (Prior) on Mar 11, 2005 at 22:11 UTC | |
by jbrugger (Parson) on Mar 12, 2005 at 11:06 UTC | |
|
Re: INSERT or UPDATE, but only when unique
by jhourcle (Prior) on Mar 12, 2005 at 00:27 UTC | |
|
Re: INSERT or UPDATE, but only when unique
by TedPride (Priest) on Mar 12, 2005 at 04:04 UTC | |
|
Re: INSERT or UPDATE, but only when unique
by saintmike (Vicar) on Mar 11, 2005 at 22:11 UTC | |
|
Re: INSERT or UPDATE, but only when unique
by jdalbec (Deacon) on Mar 12, 2005 at 01:12 UTC | |
|
Re: INSERT or UPDATE, but only when unique
by Ben Win Lue (Friar) on Mar 12, 2005 at 07:37 UTC |