Changed sql from Microsoft (T-SQL) to MySQL