Fixed a SQL issue for MySQL