User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the MySQL section within the Web Development category of DaniWeb, a massive community of 423,742 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,428 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our MySQL advertiser: Programming Forums

Trigger

Join Date: Apr 2006
Posts: 62
Reputation: Fenerbahce is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 0
Fenerbahce Fenerbahce is offline Offline
Junior Poster in Training

Trigger Help

  #1  
Apr 4th, 2008
Hi,

When i add new product into "Products" table, a trigger will add a record into "stocks" table. Example; stock=10,productId=99

How can i do that? Thanks

  1. CREATE TABLE products(
  2. productId INT(10) NOT NULL AUTO_INCREMENT,
  3. productName VARCHAR(10),
  4. PRIMARY KEY (productId));
  5.  
  6. CREATE TABLE stocks(
  7. stock INT(10),
  8. productId INT(10),
  9. FOREIGN KEY (productId) REFERENCES products(productId));
Last edited by peter_budo : Apr 4th, 2008 at 2:15 pm. Reason: Keep It Organized - please use [code] tags
AddThis Social Bookmark Button
Reply With Quote  
All times are GMT -4. The time now is 1:32 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC