經過一番研究,我現在明白我無法從子查詢中返回多列。我能做些什麼呢?多列MySQL子查詢
SELECT * FROM `users` WHERE `id` IN (SELECT `id1`, `id2` FROM `ids` WHERE `location` = 1)
結果是#1241 - Operand should contain 1 column(s)
經過一番研究,我現在明白我無法從子查詢中返回多列。我能做些什麼呢?多列MySQL子查詢
SELECT * FROM `users` WHERE `id` IN (SELECT `id1`, `id2` FROM `ids` WHERE `location` = 1)
結果是#1241 - Operand should contain 1 column(s)
試試這個:
Select users.*
from users
join ids
on users.id IN(ids.id1, ids.id2)
and ids.location = 1;
可以提供適當的創建和插入語句,以及相應的期望的結果。 – Strawberry