Reputation: 1275
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
Upvotes: 3
Views: 657
Reputation: 263703
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
Upvotes: 3