Results 1 to 3 of 3

Thread: Triggers Newbie

  1. #1
    Join Date
    Apr 2009

    Unanswered: Triggers Newbie

    Hi guys,

    Just wandering if you could help me with a mysql trigger. Its my first time coding a trigger so any help would be appreciated. I tried reading the mysql docs but find them a bit overwhelming, i tend to respond better to examples me self.

    What I am trying to do is insert into a table of users which is all good. However what I would like the trigger to do is check the submitted nice name (which is a hyphonated lower case string formed by the user submitted name and surname) and see if there is another instance of this, if there is then update the newly submitted value to be first-surname-THE ID OF THE ROW

    Any help would be appreciated on this, as I would rather start using triggers and such to update tables rather than have reams of PHP mysql statments overloading the server.

    Cheers Chaps


  2. #2
    Join Date
    Apr 2008
    Iasi, Romania
    Provided Answers: 3
    I don't know the MySQL language, but what you need is an INSTEAD OF trigger, that MySQL doesn't have yet. A normal trigger does not have the ability to update its own table (or to transform the INSERT statement into an UPDATE one).
    Florin Aparaschivei
    DB2 9.7, 10.5 on Windows
    Iasi, Romania

  3. #3
    Join Date
    Apr 2002
    Toronto, Canada
    you do not need a trigger for this

    read about INSERT syntax in da manual, and pay particular attention to the ON DUPLICATE KEY UPDATE option | @rudydotca
    Buy my SitePoint book: Simply SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts