MySQL CONCAT returns NULL if any field contain NULL

后端 未结 6 929
青春惊慌失措
青春惊慌失措 2020-11-28 04:38

I have following data in my table \"devices\"

affiliate_name  affiliate_location  model     ip             os_type    os_version 

cs1             inter             


        
6条回答
  •  长情又很酷
    2020-11-28 05:20

    Use CONCAT_WS instead:

    CONCAT_WS() does not skip empty strings. However, it does skip any NULL values after the separator argument.

    SELECT CONCAT_WS('-',`affiliate_name`,`model`,`ip`,`os_type`,`os_version`) AS device_name FROM devices
    

提交回复
热议问题