MySQL出現Incorrect integer value: '' for column 'id' at row 1解決方法


用mysql建了個表:

create table file_table ( id int auto_increment primary key, filename varchar(50) not null,filepath varchar(50) not null,update_time date);

然后用mysql寫如下的插入語句:

query = "Insert into file_table". " values ('','$name','$filepath',now())"; 

 

出現如下錯誤:

Incorrect integer value: ” for column ‘id’ at row 1

 

解決辦法:
查了一下是因為用了高版本的mysql導致的,發現高版本的mysql如果是空值應該要寫NULL或者0,所以插入語句應寫成:

query = "Insert into file_table". " values (NULL,'$name','$filepath',now())"; 

或者

query = "Insert into file_table". " values (0,'$name','$filepath',now())"; 

 

 

原文鏈接:https://blog.csdn.net/king_jie0210/article/details/52411195


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM