fix MySQL queries