Error 1136

This is a discussion on "Error 1136" within the Databases section. This forum, and the thread "Error 1136 are both part of the Program Your Website category.


 Subscribe in a reader

Go Back   Webforumz.com > Main Forums > Program Your Website > Databases

Notices




Reply
 
LinkBack Thread Tools
  #1  
Old Aug 5th, 2006, 11:46
masonbarge's Avatar
Highly Reputable Member
Join Date: Jan 2006
Location: Atlanta GA
Posts: 631
Thanks: 0
Thanked 0 Times in 0 Posts
Error 1136

This simple problem drove me nuts yesterday. I can recreate the problem. Take this simple table I just created using php MyAdmin:
Code: Select all
CREATE  TABLE  `history` ( `history_id` SMALLINT UNSIGNED NOT  NULL  AUTO_INCREMENT  PRIMARY  KEY ,
 `content` TEXT NOT  NULL ,
 `day` DATE NOT  NULL 
) ENGINE  =  MYISAM ;
MySQL automatically assigns a default "0000-00-00" to the 'day' column and collation latin1_swedish_ci to the 'content'.

I now run the following simple query directly in SQL:


Code: Select all
INSERT INTO history (content, date) VALUES ('blahblah'),('2006-08-03');
and I get the following error message:

Code: Select all
SQL query:     
              INSERT  INTO history( content, DATE ) 
VALUES ( 'blahblah'
), ( '2006-08-03'
);

     
      MySQL said:  
  #1136 - Column count doesn't match value count at row 1
Herlp!
I have a lot of tables in this database of all sizes and shapes, some of them with the same format DATE. They all work great -- I have never seen this before. I have even tried copying other (functional) tables' structures and then eliminating columns, and I still come down to this blasted 1136 error.

PS - I don't think it has anything to do with the INSERT query, as I have tried every size and shape of query I could come up with.

Last edited by masonbarge; Aug 5th, 2006 at 11:56.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote

  #2  
Old Aug 5th, 2006, 13:42
masonbarge's Avatar
Highly Reputable Member
Join Date: Jan 2006
Location: Atlanta GA
Posts: 631
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Error 1136

Well I finally got this to work but just by tinkering -- I still have no clue as to what's going on.

I changed the default date to 2006-01-01, which didn't do it. However, the table accepted the following query:

Code: Select all
INSERT INTO `history` (`history_id`, `content`, `day`) VALUES (NULL, '<li>more blah blah', '2006-08-06');
I'd still like to figure out why inserting a NULL value into the primary key makes this work -- I've never had to do anything like that before. The insertion was perfect and gave me a correct auto-incremented value for 'history_id'.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3  
Old Aug 11th, 2006, 15:07
Up'n'Coming Member
Join Date: Jan 2006
Location: East Sussex
Age: 27
Posts: 58
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Error 1136

As i understand it the reason

INSERT INTO history (content, date) VALUES ('blahblah'),('2006-08-03');

doesnt work is that VALUES ('blahblah'),('2006-08-03'); should be
VALUES ('blahblah', '2006-08-03'), but sepparating the blah and date with the () makes mysql thinks you are trying to insert another row into the history table, and so of course you dont have the same number of input values to inputfields specified. This is useful though cos you can do this

INSERT INTO history (content, date) VALUES ('content1', '2006-08-03'), ('content2', '2006-07-05'),

which will insert two rows in one query
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #4  
Old Aug 24th, 2006, 20:50
vbw vbw is offline
New Member
Join Date: Aug 2006
Location: America
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Error 1136

Gee Bee has it right. The reason for the 1136 error is the total amount of fields does not match when trying to INSERT a value in a table.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #5  
Old Aug 25th, 2006, 12:58
masonbarge's Avatar
Highly Reputable Member
Join Date: Jan 2006
Location: Atlanta GA
Posts: 631
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Error 1136

Thanks for pointing that out. As is true 99% of the time, it isn't some erudite point of programming, just a dumb syntax error.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Tags
error, 1136

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Getting the &quot;Microsoft JET Database Engine error '80040e14'&quot; error. VegaLA Classic ASP 3 Jan 26th, 2008 00:12
Keep getting error message Microsoft VBScript runtime error '800a01a8' cpando1974 Classic ASP 2 Aug 7th, 2007 12:00
Error 500 - Internal server error JasonStanley PHP Forum 3 Apr 23rd, 2007 17:56


All times are GMT. The time now is 01:25.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved