title: scheduler events in mysql using if conditions
body: <p>I have written the below query</p>
  
  <pre><code>  CREATE EVENT test_event_03
    ON SCHEDULE EVERY 1 MINUTE
    STARTS CURRENT_TIMESTAMP
    ENDS CURRENT_TIMESTAMP + INTERVAL 1 HOUR
    DO
    DECLARE cnt1 AS BIGINT
    SELECT COUNT(*) AS cnt1, d.Invoice_Date AS Invoice_Date1 FROM Depot_Sales__c AS d,  Advance_Payment_Request__c A, Supplier_Payment__c S WHERE d.Supplier_Code=A.Supplier AND d.Supplier_Code=S.Supplier AND S.Supplier=80
     IF cnt1=0 THEN
     SELECT COUNT(*) FROM Depot_Sales__c AS d 
     END IF;
  </code></pre>
  
  <p>I am getting the below error</p>
  
  <pre><code> Error Code : 1064
   You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'declare cnt1 as bigint
    SELECT COUNT(*) as cnt1, d.Invoice_Date as Invoice_Date1 ' at line 8
  
    You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near  'IF cnt1=0 THEN' at line 10
  </code></pre>
  
  <p>Why am I getting this error?</p>