Fixed SQL errors.