Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. About Triggers

About Triggers

Scheduled Pinned Locked Moved Database
perldatabasemysqllearning
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    dili1234
    wrote on last edited by
    #1

    This is my first time of creating a trigger..I tried to create trigger using mysql to count how many "2007" data are in the table when inserting new record but it not working properly it wont display how 2007 data are in my table....... My table have more than 50 data... CREATE TRIGGER No_of_Publisher_year Before Insert ON Book FOR EACH ROW SET @Count_No=New.Copyright; SET @Count_NO=0; INSERT INTO Book VALUES(14,'Programming Perl','978-0-201-70073-2','WI','2007-12-11',25.23,2,2007); SELECT Count(@Count_NO) AS 'No_of_publisher_in_year_2007' FROM Book WHERE Copyright=2007

    G 1 Reply Last reply
    0
    • D dili1234

      This is my first time of creating a trigger..I tried to create trigger using mysql to count how many "2007" data are in the table when inserting new record but it not working properly it wont display how 2007 data are in my table....... My table have more than 50 data... CREATE TRIGGER No_of_Publisher_year Before Insert ON Book FOR EACH ROW SET @Count_No=New.Copyright; SET @Count_NO=0; INSERT INTO Book VALUES(14,'Programming Perl','978-0-201-70073-2','WI','2007-12-11',25.23,2,2007); SELECT Count(@Count_NO) AS 'No_of_publisher_in_year_2007' FROM Book WHERE Copyright=2007

      G Offline
      G Offline
      GuyThiebaut
      wrote on last edited by
      #2

      dili1234 wrote:

      how many "2007" data are in the table when inserting new record

      dili1234 wrote:

      CREATE TRIGGER No_of_Publisher_year Before Insert

      The before keyword may be why you are not seeing the results you expect.

      “That which can be asserted without evidence, can be dismissed without evidence.”

      ― Christopher Hitchens

      D 1 Reply Last reply
      0
      • G GuyThiebaut

        dili1234 wrote:

        how many "2007" data are in the table when inserting new record

        dili1234 wrote:

        CREATE TRIGGER No_of_Publisher_year Before Insert

        The before keyword may be why you are not seeing the results you expect.

        “That which can be asserted without evidence, can be dismissed without evidence.”

        ― Christopher Hitchens

        D Offline
        D Offline
        dili1234
        wrote on last edited by
        #3

        But though i changed Before into after Nothing happened.I want to see the output of the result how just after inserted new value regarding the query.... :(

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups