2011-07-14 13 views
0

私はしばらくの間この質問に取り組んできました。ここでは、次のとおりです。ここMySQL:JOIN構文+選択範囲内で選択=オペランドエラー

select First10.mal, Last10.family_name, 
(select * from gender2 
JOIN 
(select * from status) as Mix1 
JOIN 
(select * from age as Mix2 order by rand() limit 10) as Mix3 
JOIN 
(select incidentid from incidentid2 as Mix4) 
as Mix5 where data='mal' and incidentid='6' and status IN ('inj','ali') and age IN ('NULL','0-17') 
order by rand() limit 100) 
from (select fn.mal, @fns := @fns + 1 as Sequence 
from (select mal from fnames where mal IS NOT NULL order by rand() limit 100) fn, 
(select @fns := 0) vars) First10 
JOIN 
(select ln.family_name, @lns := @lns + 1 as Sequence 
from (select family_name from lastnames order by rand() limit 100) ln, 
(select @lns := 0) vars) Last10 
ON First10.Sequence = Last10.Sequence; 

私の目標は、無作為化、名、姓、性別、状態、年齢、およびインシデントIDを提示する表に挿入することです。私はselect文をseperating含めて、このスクリプトを、手直しする多くの方法を試してみましたが、私はいつもこのエラーで終わるように見える:

ERROR 1241 (21000): Operand should contain 1 column(s)

人を教えてください、これは今しばらくの間、私を強調されています。..それはおそらく非常に単純な答えですが、私は自分自身をさらに混乱させています。説明が必要な場合は、尋ねてください。

答えて

0

よく、それは良い夜の眠りの後、友人からの助けのように見える、私はこのクエリが働いている。同様の質問に対する回答を探している人には、私はこれをどのように働かせるのですか。

select mal,family_name,data,age,status,incidentid 
from (select fn.mal, @fns := @fns + 1 as Sequence 
from (select mal from fnames where mal IS NOT NULL order by rand() limit 100) fn, 
(select @fns := 0) vars) as FN 
INNER JOIN 
(select ln.family_name, @lns := @lns + 1 as Sequence 
from (select family_name from lastnames order by rand() limit 100) ln, 
(select @lns := 0) vars) as LN 
INNER JOIN 
(select * from gender2) as Mix0 
INNER JOIN 
(select * from status) as Mix1 
INNER JOIN 
(select * from age as Mix2 order by rand() limit 3) as Mix3 
INNER JOIN 
(select incidentid from incidentid2 as Mix4) 
as Mix5 where data='mal' and incidentid='6' and status IN ('inj','ali') and age IN ('NULL','0-17') 
order by rand() limit 100;