Results 1 to 2 of 2

Thread: problem in creating a trigger

  1. #1
    Join Date
    May 2009
    Posts
    62
    Thanks
    19
    Thanked 3 Times in 3 Posts

    Question problem in creating a trigger

    Hi,

    I have this code in creating a trigger:

    Code:
    create trigger trigger1_trigger on trigger1 for insert
    BEGIN
    
    insert into trigger2(t2name) values("myname");
    
    END
    I don't know the rules in creating a trigger, and this code won't work. What I want to achieve was that, if I inserted a new row to trigger1 table, the new row (the name column only) will be inserted automatically to trigger2 table. How do I do that using trigger?

    LIST OF TABLES AND ITS ATTRIBUTES:

    table : trigger1
    attributes:
    t1id int not null auto_increment primary key
    t1name varchar(40)
    t1age int

    table : trigger2
    attributes:
    t2id int not null auto_increment primary key
    t2name varchar(40)

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    1. Please only post once. Your other thread in PHP has been deleted. (If you are unsure about where to post when a question overlaps between two areas, either one will be fine, but posting twice will just create confusion.)

    2. This should be easy enough to answer with google-- search "mysql trigger" (+syntax, if needed). I've never used it, but it looks like you're just trying to find the standard syntax for this, right?
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

Bookmarks

Posting Permissions

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