-foreach my $delete ( qsearch('cust_main_county', {
- 'country' => $cust_main_county->country,
- 'state' => $cust_main_county->state
- } ) ) {
+my %search = (
+ 'country' => $cust_main_county->country,
+ 'state' => $cust_main_county->state,
+ );
+
+$search{'county'} = $cust_main_county->county
+ if $cust_main_county->city;
+
+foreach my $delete ( qsearch('cust_main_county', \%search) ) {