WHERE pan_number NOT REGEXP '^[A-Z]{5}[0-9]{4}[A-Z]$'; ...