我有以下3列表格:

+----+---------+------------+| ID | First | Last |+----+---------+------------+| 1 | Maurice | Richard || 2 | Yvan | Cournoyer || 3 | Carey | Price || 4 | Guy | Lafleur || 5 | Steve | Shutt |+----+---------+------------+

如果我想在(Maurice,Guy)中寻找所有人,可以执行select * from table where first in (Maurice,Guy)

如果我只想找到Maurice Richard,可以执行select * from table where first = "Maurice" and last = "Richard"

如何制作地图(多个数组)?

[ [Maurice, Richard] [Guy,Lafleur] [Yvan,Cournoyer]]

如果我有任意数量的条目,则无法构造长的复杂where (first = "Maurice" and last = "Richard") or (first = "Guy" and last = "Lafleur") or ....

我该如何在道德上等同于where (first, last) in ((Guy,Lafleur),(Maurice,Richard))

最佳答案

您可以像描述它那样进行:

SELECT *
FROM mytable
WHERE (first, last) IN (('Guy','Lafleur'),('Maurice','Richard'))


Demo here

关于mysql - 如何在MySQL中选择具有与值映射匹配的多列的记录?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/40063523/

10-11 08:29