Fix for mysql query