SQL 错误:操作数应包含 1 列
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1713829/
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
SQL ERROR: Operand should contain 1 column(s)
提问by newbie
I have this query and I get error "Operand should contain 1 column(s)", whats wrong in my query?
我有这个查询,我收到错误“操作数应该包含 1 列”,我的查询有什么问题?
SELECT * FROM contact AS b WHERE b.id IN
(
SELECT *
FROM contact AS e
WHERE e.firstname LIKE ?
OR e.lastname LIKE ?
OR e.email LIKE ?
OR e.phone LIKE ?
OR e.company LIKE ?
OR e.profession LIKE ?
OR e.mobile LIKE ?
)
回答by davek
The IN operator expects a list of values which match whatever you are comparing against: the columnb.id in your case. So replace this
IN 运算符需要一个与您正在比较的内容相匹配的值列表:您的情况下的 columnb.id。所以更换这个
WHERE b.id IN (SELECT *
with this
有了这个
WHERE b.id IN (SELECT id
回答by Konamiman
The second select should be SELECT id
insetad of SELECT *
.
第二个选择应该SELECT id
插入SELECT *
.
回答by KB22
回答by Wael Dalloul
SELECT * FROM
the problem in the above statement, because you are selecting more than one column,
上面语句中的问题,因为你选择了不止一列,
change it to
将其更改为
SELECT * FROM contact AS b WHERE b.id IN (SELECT e.ID FROM contact AS e WHERE e.firstname
LIKE ? OR e.lastname LIKE ? OR e.email LIKE ? OR e.phone LIKE ? OR e.company LIKE ? OR
e.profession LIKE ? OR e.mobile LIKE ?)
回答by shahkalpesh
SELECT * FROM contact AS b WHERE b.id IN (SELECT e.Id FROM contact AS e WHERE e.firstname
LIKE ? OR e.lastname LIKE ? OR e.email LIKE ? OR e.phone LIKE ? OR e.company LIKE ? OR
e.profession LIKE ? OR e.mobile LIKE ?)
Instead of SELECT * FROM contact
, it should be a column which contains values matching to b.id
.
而不是SELECT * FROM contact
,它应该是包含与 匹配的值的列b.id
。
So, it should be SELECT e.Id FROM contact
所以,应该是 SELECT e.Id FROM contact