MySQL Syntax Error: "Operand should contain 1 column(s)" in an INSERT-SELECT Query
When executing an INSERT-SELECT query, MySQL may throw an error stating "Operand should contain 1 column(s)". To troubleshoot this issue, consider the following:
Syntax
The correct syntax for an INSERT-SELECT query is:
1 2 3 4 |
|
In the provided query:
1 2 3 4 |
|
the括号in the SELECT clause are incorrect. Remove them, yielding:
1 2 3 4 |
|
Data Size
After correcting the syntax, if the error persists, consider the size of the data involved in the query. MySQL limits the number of rows that can be returned by a SELECT statement (MAX_JOIN_SIZE). To avoid this error for large data sets, execute:
1 |
|
before running the query. This will increase the limit and allow the query to execute successfully.
Example
Using the corrected syntax and setting SQL_BIG_SELECTS, the modified query becomes:
1 2 3 4 5 6 |
|
Execute this query to insert the data from temp_cheques into the VOUCHER table.
The above is the detailed content of Why Does My MySQL INSERT-SELECT Query Return 'Operand should contain 1 column(s)'?. For more information, please follow other related articles on the PHP Chinese website!