automatically overwrite row

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • wesomon99
    New Member
    • Jun 2007
    • 16

    #1

    automatically overwrite row

    I have a database with submissions inserted from a web server.
    If a submission is made again (i.e. with same user_id and problem_id), I want it to overwrite the row in the database. Currently, when I try to make the insert statement again, it obviously just fails and gives me a duplicate row error. As I don't know if a row is going to exist or not, is there a simple way to automatically insert/overwrite?

    Thanks, Wes
  • pbmods
    Recognized Expert Expert
    • Apr 2007
    • 5821

    #2
    Heya, wesomon99.

    MySQL has exactly what you're looking for:
    http://dev.mysql.com/doc/refman/5.0/en/replace.html

    Comment

    • wesomon99
      New Member
      • Jun 2007
      • 16

      #3
      Originally posted by pbmods
      Heya, wesomon99.

      MySQL has exactly what you're looking for:
      http://dev.mysql.com/doc/refman/5.0/en/replace.html

      Oh wow...replace will also insert...
      Well thank you for clearing this up for me.
      ~Wes

      Comment

      • pbmods
        Recognized Expert Expert
        • Apr 2007
        • 5821

        #4
        Heya Wes.

        No problem.

        Good luck with your project, and if you ever need anything, post back anytime :)

        Comment

        Working...