title: Mysql trigger or stored procedure to update column A on update of column B in same table
body: <p>I have created a library database and one of the table is <code>transaction</code> which is as follows</p>
  
  <pre><code>CREATE TABLE action
  (
  t_id int NOT NULL AUTO_INCREMENT,
  b_id int,
  m_id int,
  borrow_timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
  is_returned Bool Default 0,
  is_lost Bool,
  is_damaged Bool,
  return_timestamp TIMESTAMP,
  f_id int,
  PRIMARY KEY (t_id),
  CONSTRAINT fk_bookId FOREIGN KEY (b_id) REFERENCES book(b_id),
  CONSTRAINT fk_memberId FOREIGN KEY (m_id) REFERENCES member(m_id),
  CONSTRAINT fk_fineId FOREIGN KEY (f_id) REFERENCES fine(f_id)
  );
  </code></pre>
  
  <p>I want to update <code>return_timestamp</code> arrtibute to the timestamp which is when <code>is_returned</code> is changed to <code>1</code></p>
  
  <p>I tried this </p>
  
  <pre><code>CREATE TRIGGER update_return_timestamp
  AFTER UPDATE
  ON action FOR EACH ROW
  
  BEGIN
  DECLARE return_timestamp timestamp;
  
     SELECT is_returned FROM action
     IF is_return IS 1
          BEGIN
             INSERT INTO transaction (return_timestamp) VALUES (now())
          END
      COMMIT TRANSACTION
  END
  </code></pre>
  
  <p>Where am I going wrong? Or what is the correct approach? I don't know how to do this</p>