List:General Discussion« Previous MessageNext Message »
From:Paul DuBois Date:September 13 2005 4:48am
Subject:Re: "Operand should contain 1 column" error
View as plain text  
At 13:19 +0900 9/13/05, Dave wrote:
>(Topic moved from "Copying data stored in different field formats 
>from one table to another")
>
>MySQL General List,
>
>   Server specifications:
>   MySQL 4.1.3-beta, phpMyAdmin 2.5.7-pl1, PHP 4.3.8
>   My specifications:
>   MySQL beginner, PHP intermediate, HTML and CSS advanced.
>
>   The situation:
>   While trying to copy data over from one table to another, I have 
>encountered the following error:
>#1241 - Operand should contain 1 column(s)
>
>    The query that I used which led to this error was this:
>INSERT  INTO forum_members( dateRegistered, realName, ID_MEMBER, 
>memberName, emailAddress, active, keitai, number, admin, cardpic, 
>cardbio, hofpic, hofbio, nickname, contactMe, showMe, websiteUrl )
>SELECT ( UNIX_TIMESTAMP( joindate ) , CONCAT_WS(  ' ', firstname, 
>lastname ) , id, username, email, active, keitai, number, admin, 
>cardpic, cardbio, hofpic, hofbio, nickname, contactMe, showMe, 
>website )
>FROM members
>
>   The Questions:
>   What do I need to do to my query to remove this error and 
>successfully copy the data from one table to another.
>
>    What I've done so far:
>    Of course I looked on Google for explanations of this error. One 
>web page I looked at said:
>"This error will occur in cases like this:
>SELECT (SELECT column1, column2 FROM t2) FROM t1;"
>    But I am not running a SELECT within a SELECT.

No, but the parentheses around the select columns form a row constructor,
that is a tuple of values rather than a list of scalars.  Here's a simpler
case that illustrates the problem:

mysql> select 1,2;
+---+---+
| 1 | 2 |
+---+---+
| 1 | 2 |
+---+---+
1 row in set (0.00 sec)

mysql> select (1,2);
ERROR 1241 (21000): Operand should contain 1 column(s)

I'm curious --- why do you have the extra parentheses in there, anyway?

>    Other web sites all seemed to indicate this was an issue of 
>nesting queries within each other, particularly SELECT within 
>SELECT. But my query seems more straight forward than that, so I'm 
>not sure if that advice applies.

-- 
Paul DuBois, MySQL Documentation Team
Madison, Wisconsin, USA
MySQL AB, www.mysql.com
Thread
"Operand should contain 1 column" errorDave13 Sep
  • Re: "Operand should contain 1 column" errorJasper Bryant-Greene13 Sep
    • Re: "Operand should contain 1 column" error [SOLVED]Dave13 Sep
  • Re: "Operand should contain 1 column" errorPaul DuBois13 Sep
    • Re: "Operand should contain 1 column" errorDave13 Sep