3

I am trying to make an query on my database, I want to move all the rows that have eventcodes.PRIORITY=1 and g052013.WCODE=eventcodes.WCODE, as you can see I copy all the rows from the last month to the new month. the error I get is :
#1136 - Column count doesn't match value count at row 1
and I have the same number of cols in the tables.
What I am doing wrong here?
Here is my query :

insert into g062013
select g052013.pnumber,g052013.id,
g052013.Ccode,
g052013.WCODE,
g052013.ndate,
g052013.TIMECALL,
g052013.EventHandling,
g052013.Endtimecare,
g052013.User,
g052013.TIMEARRIAVAL,
g052013.FREEDATA,
g052013.sendtime from
g052013 RIGHT JOIN eventcodes ON g052013.WCODE=eventcodes.WCODE AND   eventcodes.PRIORITY='1' 
WHERE gyoman052013.EventHandling!=2
1
  • Error is telling you that number of columns doesn't match insert fields, can you show your table schema? Commented Jun 3, 2013 at 7:47

1 Answer 1

3

When you are using implicit syntax of INSERT statement wherein you did not specify the column names, the number of values must match with the number of columns in the table otherwise wise you'll receive an error message

#1136 - Column count doesn't match value count at row 1

To fix this problem, you need to explicitly define the column names on where the values will be saved. Ex,

INSERT INTO tableName(col1, col2, col3)
SELECT val1, val2, val3
FROM tableName
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, I did it first and its not working then I remove the "(" ")" after the SELECT and its worked.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.