mysql query fixed bug