title: Mysql sql error #1064
body: <blockquote>
    <p>check the manual that corresponds to your MySQL server version for the right syntax to use near: <code>'SELECT count(*) FROM capacity 
        WHERE
         server=NEW.server
        AND
         feed'</code> at line 2</p>
  </blockquote>
  
  <p>my code:</p>
  
  <pre><code>DROP TRIGGER IF EXISTS newsmonitoringrawdata.TNTInsertionTrigger;
  
  CREATE TRIGGER TgtInsertionTrigger BEFORE INSERT ON tnews
    FOR EACH ROW BEGIN
  SET @isRecordCreated = 
   SELECT count(*) FROM capacity
   WHERE
   server=NEW.server
   AND
   feed=NEW.Feed 
   AND 
   date_Format(streamdt,'%Y-%m-%d %H:%i')=date_Format(NEW.StreamDT,'%Y-%m-%d %H:%i');
  
   IF @isRecordCreated&gt;0 THEN 
      UPDATE capacity 
      SET MsgNumber=MsgNumber+1, 
      size=size+NEW.MSize
      WHERE 
      server=NEW.server
      AND
       feed=NEW.feed
      and
       date_Format(streamdt,'%Y-%m-%d %H:%i')=date_Format(NEW.StreamDT,'%Y-%m-%d %H:%i');
   ELSE 
      INSERT INTO capacity(server, feed, streamdt, msgNumber, size) 
      VALUES
      (
          NEW.server,
          NEW.feed,
          date_Format(NEW.StreamDT,'%Y-%m-%d %H:%i:00'),
          1,
          NEW.size
      );  
   END IF; 
  
  END
  </code></pre>