-- note: a left join is required because City is an EAV attribute
-- i.e. if a customer has no City information, then there will be no
-- corresponding entry in the customer_address_entity_varchar db table

SELECT customer_address_entity.entity_id
FROM customer_address_entity
LEFT JOIN customer_address_entity_varchar ON (
    customer_address_entity.entity_id = customer_address_entity_varchar.entity_id
    AND customer_address_entity_varchar.attribute_id IN (
        -- get "city" attribute id
        SELECT attribute_id
        FROM eav_attribute
        WHERE entity_type_id = 2
          AND attribute_code = 'city'
    )
)
WHERE customer_address_entity_varchar.value IS NULL
ORDER BY entity_id;


-- TODO - run the following SQL on the customer_address_entity_varchar db table for every single entry returned by the previous SQL:
--
-- INSERT INTO customer_address_entity_varchar(`entity_type_id`, `attribute_id`, `entity_id`, `value`)
-- VALUES (2, 24, $id, 'SG');