Fixed MySQL queries