mysql基础 GROUP_CONCAT()

时间:2022-04-23 07:45:07

 

 

SELECT
    GROUP_CONCAT(
    CONCAT_WS(
    ---,
    TRANSIT_PORT_EN,
IF
    ( TRANSIT_PORT_CODE IS NULL OR TRIM(TRANSIT_PORT_CODE) = ‘‘, , TRANSIT_PORT_CODE ),
IF
    ( TRANSIT_ROUTE_CODE IS NULL OR TRIM(TRANSIT_ROUTE_CODE) = ‘‘, , TRANSIT_ROUTE_CODE ),
IF
    ( TRANSIT_VESSEL IS NULL OR TRIM(TRANSIT_VESSEL) = ‘‘, , TRANSIT_VESSEL ),
IF
    ( TRANSIT_VOYAGE IS NULL OR TRIM(TRANSIT_VOYAGE) = ‘‘, , TRANSIT_VOYAGE ) 
    ) 
ORDER BY
    TRANSIT_SORT SEPARATOR >>> 
    ) 

---- 不必须要 加 group by