我想用一个查询在我的数据库中选择两个不同的组:
这样的事情:
SELECT * FROM RECORDS
在哪里日期='星期一' AND plan ="每周"
在哪里日期='星期三' AND plan ="每日"
我可以合并这两个(或更多)" wheles"在一个查询?怎么样?
我希望我足够清楚:)
答案 0 :(得分:4)
你好吗:
SELECT r.*
FROM RECORDS r
WHERE (r.DATE = 'Monday' AND r.plan = "Weekly") OR
(r.DATE = 'Wednesday' AND r.plan = "Daily")
答案 1 :(得分:1)
您也可以使用union
SELECT * FROM RECORDS
WHERE DATE = 'Monday' AND plan = "Weekly"
UNION ALL
SELECT * FROM RECORDS
WHERE DATE = 'Wednesday' AND plan = "Daily"
好运!