title: Conversion ms sql function into mysql
body: <p>I'm facing a problem while converting ms sql function into mysql. Here is ms sql function code:</p>
  
  <pre><code>CREATE FUNCTION [crewu2].[isAvailable] (@OwnerID int, @DateFrom Smalldatetime, @DateTo Smalldatetime)  
  RETURNS bit AS  
  BEGIN  
      DECLARE @t bit  
      IF @DateFrom IS NULL or @DateTo IS NULL 
          or EXISTS (select DateID
                       from [client_BlackDates]
                      where OwnerID=@OwnerID 
                        and ((DateFrom&lt;=@DateFrom and @DateFrom&lt;=DateTo) 
                              or (DateFrom&lt;=@DateTo and @DateTo&lt;=DateTo)))  
          SET @t=0  
      ELSE  
          SET @t=1  
  RETURN @t  
  END  
  </code></pre>
  
  <p>And here is converted in mysql:</p>
  
  <pre><code>DELIMITER $$  
  CREATE FUNCTION isAvailable (OwnerID INT, DateFrom DATETIME, DateTo DATETIME)  
  RETURNS BIT   
  BEGIN  
      DECLARE t BIT;  
      IF DateFrom IS NULL OR DateTo IS NULL
          OR EXISTS (SELECT DateID
                       FROM client_BlackDates
                      WHERE OwnerID=OwnerID 
                        AND ((DateFrom&lt;=DateFrom AND DateFrom&lt;=DateTo)
                              OR (DateFrom&lt;=DateTo AND DateTo&lt;=DateTo)))  
          SET t=0;  
      ELSE  
          SET t=1;  
      RETURN t  
  END $$  
  DELIMITER;
  </code></pre>
  
  <p>but it gives me following error:</p>
  
  <p><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 'SET t=0;
  ELSE
  SET t=1;
  RETURN t
  END' at line 6
  </code></p>
  
  <p>Please anyone help me regarding this.</p>