操作数应该包含1列



你好,我试着运行这个查询,但是这个错误出现

#1241 - Operand should contain 1 column(s)
下面是代码:
SELECT 
(SELECT kk.namakk, anggkk.nama AS istri
FROM kk
JOIN anggkk
USING ( idkk ) 
WHERE anggkk.hubungan =  "istri"),
(SELECT anggkk.nama AS anak, YEAR( CURDATE( ) ) - YEAR( anggkk.ttl ) AS usia_anak
FROM anggkk
JOIN kk
USING ( idkk ) 
WHERE anggkk.hubungan =  "anak")
FROM kk, anggkk
GROUP BY kk.idkk

我的错误在哪里?谢谢你的帮助!

Operand should contain 1 column(s),意味着在子查询中有许多列返回。

你需要将limit 1添加到像这样的一列

   SELECT 
 (SELECT kk.namakk, anggkk.nama AS istri
 FROM kk
 JOIN anggkk
 USING ( idkk ) 
 WHERE anggkk.hubungan =  "istri"
 LIMIT 1),
 (SELECT anggkk.nama AS anak, YEAR( CURDATE( ) ) - YEAR( anggkk.ttl ) AS usia_anak
 FROM anggkk
 JOIN kk
 USING ( idkk ) 
 WHERE anggkk.hubungan =  "anak"
 LIMIT 1)
 FROM kk, anggkk
 GROUP BY kk.idkk

或者你需要更详细地说明你选择的列

相关内容

  • 没有找到相关文章