gpt4 book ai didi

mysql - 在mysql输出文件中保留十进制0

转载 作者:行者123 更新时间:2023-11-30 21:48:09 25 4
gpt4 key购买 nike

所以我有这样的表结构,

CREATE TABLE DATA_0 (ID BIGINT(15), I_R_A int(10) DEFAULT NULL, I_NO varchar(200) DEFAULT NULL, V_x double(10,1) DEFAULT NULL);

像这样的示例数据,

ID,I_R_A,I_NO,V_x
1,10000,9895987650, 10000.0
2,60,2424, 60.0
3,70,34, 70.0
4,80,34245, 80.0

当执行以下输出文件查询时-

SELECT ID,I_R_A,I_NO,V_x INTO OUTFILE "/home/user/out.txt" FIELDS TERMINATED BY ',' LINES TERMINATED BY '\r\n' FROM DATA_0;

我的输出文件看起来像这样-

ID,I_R_A,I_NO,V_x
1,10000,9895987650, 10000
2,60,2424, 60
3,70,34, 70
4,80,34245, 80

如您所见,十进制 0 已从 V_x删除。我怎样才能保留这个0

最佳答案

使用FORMAT功能

SELECT ID,I_R_A,I_NO, REPLACE(FORMAT(V_x, 1), ',', '')
INTO OUTFILE "/home/user/out.txt"
FIELDS TERMINATED BY ',' LINES TERMINATED BY '\r\n'
FROM DATA_0;

关于mysql - 在mysql输出文件中保留十进制0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48502490/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com