2

I want to create a trigger on one of the Table, lets say AssetDataTable In which the values gets populated via a Windows service, so basically I want to do is

SELECT * FROM AssetDataTable Where AssetID = 105 ORDER by 1 DESC;

I get this one row back, Now if any of the column value is zero, it should update in another StatusTable

AssetID   Column1  Column2  Column3  Column4  Column5
 105      18.8      19.9     13.0     18.7     0

Now In My StatusTable, the row should become

       AssetID  Status 
         105     0

I really don't have any clue how to do, any ideas?

1 Answers1

0

Try with this example this is the guidelines for your desired result i hope this may helps you

DELIMITER //

 CREATE TRIGGER contacts_after_update
 AFTER UPDATE
 ON contacts FOR EACH ROW

 BEGIN

  DECLARE vUser varchar(50);

-- Find username of person performing the INSERT into table

  SELECT USER() INTO vUser;

-- Insert record into audit table

  INSERT INTO contacts_audit
   (   contact_id,
   updated_date,
   updated_by)
   VALUES
   (  NEW.contact_id,
  SYSDATE(),
  vUser );

 END; //

 DELIMITER ;
Vamshi .goli
  • 522
  • 4
  • 13
  • you can refer this you get valuable information......http://stackoverflow.com/questions/16892070/mysql-after-insert-trigger-which-updates-another-tables-column – Vamshi .goli Jan 06 '15 at 13:57