mysql基础 GROUP_CONCAT()

 

 

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

你可能感兴趣的:(mysql基础 GROUP_CONCAT())