Fix error in MySQL query