Fix query for MySQL