Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySQL error 1241: Operand should contain 1 column(s)

I am trying to Insert data from a table1 into table2

insert into table2(Name,Subject,student_id,result) select (Name,Subject,student_id,result) from table1; 

Key for table2 is student_id.

Assume that there are not any duplicates.

I get the error: MySQL error 1241: Operand should contain 1 column(s)

There are only four columns in table2.

like image 712
Kumaran Senapathy Avatar asked Apr 04 '13 19:04

Kumaran Senapathy


2 Answers

Syntax error, remove the ( ) from select.

insert into table2 (name, subject, student_id, result) select name, subject, student_id, result from table1; 
like image 56
David Avatar answered Sep 19 '22 08:09

David


Just remove the ( and the ) on your SELECT statement:

insert into table2 (Name, Subject, student_id, result) select Name, Subject, student_id, result from table1; 
like image 43
fthiella Avatar answered Sep 21 '22 08:09

fthiella



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!