错误 #1241 - Mysql 中的操作数应包含 1 列
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16945867/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Error #1241 - Operand should contain 1 column(s) in Mysql
提问by dpfarhad
I just try following query:
我只是尝试以下查询:
SELECT *,
(
SELECT count(*)
FROM users
where users.email=calls.email
) as ureg,
(
SELECT sum(qty)
FROM product
where product.owner in
(SELECT *
from users
where users.email=calls.email)
) as pop
FROM calls
order by calls.data desc
LIMIT 0,20
but I get following error :
但我收到以下错误:
#1241 - Operand should contain 1 column(s)
How should I fix my query?
我应该如何解决我的查询?
Edit:
by changing
SELECT * from users where users.email=calls.emailto
SELECT id from users where users.email=calls.email
编辑:通过更改
SELECT * from users where users.email=calls.email为
SELECT id from users where users.email=calls.email
it works because the query searches for product.owner in bunch of ids that exist in users
它起作用是因为查询id在用户中存在的一堆s 中搜索 product.owner
回答by Explosion Pills
where product.owner in (SELECT *
product.owneris one column, so the subquery should return one column (whatever corresponds to product.owner).
product.owner是一列,所以子查询应该返回一列(对应于product.owner)。
回答by echo_Me
try this
尝试这个
SELECT calls.*, count(users.*) as ureg, sum(twons.qty) as pop
FROM calls
INNER JOIN users ON users.email=calls.email
INNER JOIN towns ON towns.id = users.town
^^^^^^^^^^^^^^^^^^^^^^^^^^--you have to correct this to your table column names
order by data desc
LIMIT 0,20
- you have to correct this
ON towns.id = users.townto your tables names
- 您必须将此更正
ON towns.id = users.town为您的表名称

