mysql表导出csv空值_将MYSQL表导出到CSV时如何处理空字段

bd96500e110b49cbb3cd949968f18be7.png

Right now when I export MYSQL tables to CSV files, I'm getting \N for NULL fields in the database which is expected. If there a way to change the \N output to just an empty string when exporting tables to csv?

Thanks

SELECT 'CU_CustomerID','CU_UserName','CU_Password','CU_Email','CU_Company','CU_Comment','CU_LastBasket','CON_FirstName','CON_MiddleI','CON_LastName','CON_Address1','CON_Address2','CON_City','CON_State','CON_Province','CON_Country','CON_Zip','CON_Phone1','CON_Phone2'

UNION

SELECT T1.CU_CustomerID,T1.CU_UserName,T1.CU_Password,T1.CU_Email,T1.CU_Company,T1.CU_Comment,T1.CU_ShopperPoints,T2.CON_FirstName,T2.CON_MiddleI,T2.CON_LastName,T2.CON_Address1,T2.CON_Address2,T2.CON_City,T2.CON_State,T2.CON_Province,T2.CON_Country,T2.CON_Zip,T2.CON_Phone1,T2.CON_Phone2

FROM CUSTOMERS AS T1

INNER JOIN CONTACT AS T2 ON T1.CU_CustomerID = T2.CON_CustomerID

WHERE T1.CU_CustomerID BETWEEN 0 AND 1000

INTO OUTFILE 'customers.csv'

FIELDS TERMINATED BY ','

ENCLOSED BY '"'

解决方案If the FIELDS ESCAPED BY character is empty, no characters are escaped

and NULL is output as NULL, not \N. It is probably not a good idea to specify an empty escape character,

particularly if field values in your data contain any of the characters in the list just given.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值