本文介绍了错误 #1241 - Mysql 中的操作数应包含 1 列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我只是尝试以下查询:

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

但我收到以下错误:

#1241 - Operand should contain 1 column(s)

我应该如何解决我的查询?

How should I fix my query?

通过改变SELECT * from users where users.email=calls.emailSELECT id from users where users.email=calls.email

之所以有效,是因为查询在用户中存在的一堆 id 中搜索 product.owner

it works because the query searches for product.owner in bunch of ids that exist in users

推荐答案

where product.owner in (SELECT *

product.owner 是一列,所以子查询应该返回一列(对应于 product.owner 的任何内容).

product.owner is one column, so the subquery should return one column (whatever corresponds to product.owner).

这篇关于错误 #1241 - Mysql 中的操作数应包含 1 列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-08 20:29