I am getting the MySQL error #1264 - Out of range value adjusted for column 'id' at row 1 when I try to run my INSERT query. With me MySQL server version is 5.0.24a-community-max-nt-log and my table structure is as follow:
CREATE TABLE `tbl_oer` ( `id` int(11) NOT NULL auto_increment, `programid` int(11) default NULL, `workshop` varchar(250) default NULL, `fname` varchar(250) default NULL, `lname` varchar(250) default NULL, `designation` varchar(250) default NULL, `organization` varchar(250) default NULL, `experience` varchar(250) default NULL, `contactno` varchar(250) default NULL, `mobile` varchar(255) default NULL, `email` varchar(250) default NULL, `nominatedby_section_b` varchar(250) default NULL, `designation_section_b` varchar(250) default NULL, `address_section_b` varchar(250) default NULL, `telephone_section_b` varchar(250) default NULL, `mobile_section_b` varchar(255) default NULL, `fax_section_b` varchar(250) default NULL, `email_section_b` varchar(250) default NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1; My sample insert query, which gets error the error $1264 is below:
INSERT INTO tbl_oer values('', '18', '', 'testsaleem', 'test', '', '', '', '', '', 'saleem@website-developer-service.com', '', '', '', '', '', '', ''); Can you help to fix problem if exists in the above query?
Answer No: 97
The error 1264 Out of range value adjusted for column mostly occurs when INSERT query makes try to insert an empty value into a NOT NULL field. So 'id' is a NOT NULL field in your table against which you are inserting empty ('') value. Means, you must pass some value instead of empty value against NOT NULL type field. Further, because your id field is also AUTO_INCREMENT so you can change your query by passing NULL value against the id field. Change your query from:
INSERT INTO tbl_oer values('', '18', '', 'testsaleem', 'test', '', '', '', '', '', 'saleem@website-developer-service.com', '', '', '', '', '', '', ''); to
INSERT INTO tbl_oer values(NULL, '18', '', 'testsaleem', 'test', '', '', '', '', '', 'saleem@website-developer-service.com', '', '', '', '', '', '', '');
Related MySQL FAQs to the Above FAQ
|