Search code examples
mysqlsqlselectinsertmysql-error-1241

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.


Solution

  • Syntax error, remove the ( ) from select.

    insert into table2 (name, subject, student_id, result)
    select name, subject, student_id, result
    from table1;