每次我尝试在我的数据库中插入一条insert语句时,我都会得到一个“不正确的十进制值:'NULL‘for column 'bounty3’at row 1”错误。如何将空值插入到decimal数据类型中?我应该把默认值设为0.00吗?
Incorrect decimal value: '' for column 'bounty3' at row 1 Whole query: INSERT INTO songs (userid, wavURL, mp3URL, genre, songTitle, BPM, insWanted, bounty, insWanted2, bounty2, insWanted3, bounty3, insWanted4, bounty4, insWanted5, bounty5, insWanted6, bounty6, insWanted7, bounty7, insWanted8, bounty8, insWanted9, bounty9, insWanted10, bounty10) VALUES ('12534545', '/audio/wav/jqmrgpfcMichael/135259578210secreason.wav', '/audio/mp3/jqmrgpfcMichael/135259578210secreason.mp3', 'Rock/Funk', 'titlee', '120', 'bass', '20.00', 'guitar', '20.00', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '')我也尝试过使用空值执行此语句。下面是错误:
Incorrect decimal value: 'NULL' for column 'bounty3' at row 1 Whole query: INSERT INTO songs (userid, wavURL, mp3URL, genre, songTitle, BPM, insWanted, bounty, insWanted2, bounty2, insWanted3, bounty3, insWanted4, bounty4, insWanted5, bounty5, insWanted6, bounty6, insWanted7, bounty7, insWanted8, bounty8, insWanted9, bounty9, insWanted10, bounty10) VALUES ('12534545', '/audio/wav/jqmrgpfcMichael/143922765110secreason.wav', '/audio/mp3/jqmrgpfcMichael/143922765110secreason.mp3', 'Rock/Funk', 'title', '110', 'bass', '110.00', 'guitar', '20.00', 'NULL', 'NULL', 'NULL', 'NULL', 'NULL', 'NULL', 'NULL', 'NULL', 'NULL', 'NULL', 'NULL', 'NULL', 'NULL', 'NULL', 'NULL', 'NULL')发布于 2011-09-18 14:33:18
如果需要默认值,请使用空白,而不是null。
发布于 2011-09-18 14:42:48
哦..。您正在尝试向bounty3中插入空字符串'‘。将其替换为NULL。我也注意到其他可能的数值是空字符串,例如bonty4。对于数值,应将所有空字符串替换为NULL。
例如: mysql_query("INSERT INTO empty_number,number VALUES(NULL,1)");
编辑:嘿嘿明白了,你不能将NULL作为' NULL‘插入到一个数值中,因为这是一个字符串,你应该作为NULL插入而不带引号
发布于 2014-01-30 00:12:00
我刚刚在MySql 5.1.61中处理了这个问题。如果服务器处于严格模式,则必须在小数字段中输入0而不是'‘。禁用严格模式允许您只使用do '‘来填充空值。
https://stackoverflow.com/questions/7459875
复制相似问题