UPDATE nodes n SET
location_address = (SELECT
CASE
WHEN post_address != '' THEN post_address
ELSE address
END as address
FROM customers c WHERE
c.id = n.ownerid )
WHERE location_address IS NULL OR location_address = '';
UPDATE nodes n SET
location_city = (SELECT
CASE
WHEN post_city != '' THEN post_city
ELSE city
END as city
FROM customers c WHERE
c.id = n.ownerid)
WHERE location_city IS NULL OR location_city = '';
UPDATE nodes n SET
location_zip = (SELECT
CASE
WHEN post_zip != '' THEN post_zip
ELSE zip
END as zip
FROM customers c WHERE
c.id = n.ownerid)
WHERE location_zip IS NULL OR location_zip = '';
UPDATE netdevices nd SET location = (
SELECT CONCAT(location_city, ', ',location_address) AS location
FROM nodes n
WHERE n.netdev =
nd.id LIMIT 1
)
WHERE location IS NULL OR location = ''