CONCAT_WS() does not skip empty strings. However, it does skip any NULL values after the separator argument.
NULLIF(expr1,expr2) Returns NULL if expr1 = expr2 is true, otherwise returns expr1.
SO your query could be:
NULLIF(expr1,expr2) Returns NULL if expr1 = expr2 is true, otherwise returns expr1.
SO your query could be:
SELECT
CONCAT_WS(', ',
NULLIF(location_address1, ''),
NULLIF(location_address2, ''),
NULLIF(location_town, ''),
NULLIF(location_region, ''),
NULLIF(location_postcode, ''),
NULLIF(country_name, '')
) AS address
FROM
countries c
WHERE
c.country_id = locations.country_id LIMIT 1
No comments:
Post a Comment