title: How to make real time trigger in MySQL?
body: <p>I'm currently working on a small airline project and I have stuck in this problem.
  The problem is that I want to update the field DABAY (status) in below table to 1 when our current time passed the time in field THOIGIANBAY (time will fly).
  I have made a trigger below the table code but it had error syntax and it didn't work.
  Thanks guys for helping!</p>
  
  <pre><code>CREATE TABLE chuyenbay ( 
      MACHUYENBAY varchar(5) NOT NULL,
      MAMAYBAY varchar(6) NOT NULL,
      SANBAYDI varchar(3) NOT NULL,
      SANBAYDEN varchar(3) NOT NULL,
      THOIGIANBAY datetime NOT NULL, --time will fly
      THOIGIANDEN datetime NOT NULL,
      TRANSITION varchar(3) DEFAULT NULL
      DABAY bit(1) DEFAULT '0'  --status
  )
  
  DELIMITER $$
  CREATE TRIGGER CHUYENBAY_VE_capnhat_TRANGTHAI
  AFTER INSERT ON chuyenbay
  FOR EACH ROW
  BEGIN
      DECLARE thoigianbandau datetime;
      SELECT THOIGIANBAY INTO @thoigianbandau
      FROM chuyenbay
      WHERE chuyenbay.MACHUYENBAY = inserted.MACHUYENBAY
      IF (NOW() &gt; @thoigianbandau)
          THEN 
              UPDATE chuyenbay SET chuyenbay.DABAY = 1;
              UPDATE ve SET ve.TRANGTHAI = 2;
      END IF;
  END; $$
  DELIMITER ;
  </code></pre>