我有这个查询,我收到错误“操作数应该包含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 ?
)
答案 0 :(得分:12)
IN运算符需要一个与您所比较的值匹配的值列表:在您的情况下为columnb.id。所以替换这个
WHERE b.id IN (SELECT *
用这个
WHERE b.id IN (SELECT id
答案 1 :(得分:7)
第二个选择应为SELECT id
而不是SELECT *
。
答案 2 :(得分:3)
答案 3 :(得分:2)
SELECT * FROM
上述语句中的问题,因为您选择了多个列,
将其更改为
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 ?)
答案 4 :(得分:1)
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 ?)
它应该是一个包含与SELECT * FROM contact
匹配的值的列,而不是b.id
。
所以,它应该是SELECT e.Id FROM contact