有什么方法可以缩短/更轻松地阅读以下 SQL 来连接字符串。
SELECT
CONCAT(
IF(location_address1 != '',
CONCAT(location_address1, ", "),
""
),
IF(location_address2 != '',
CONCAT(location_address2, ", "),
""
),
IF(location_town != '',
CONCAT(location_town, ", "),
""
),
IF(location_region != '',
CONCAT(location_region, ", "),
""
),
IF(location_postcode != '',
CONCAT(location_postcode, ", "),
""
),
c.country_name
)
FROM
countries c
WHERE
c.country_id = locations.country_id LIMIT 1