这里SQL的极端新手。有没有更简单的方法来做到这一点?SQL简单和替代?
SELECT event_type, flow, userid
FROM checkpoints_esc
WHERE date='2013-05-14' AND event_type='flow_started' AND flow='1921474754'
OR flow='3326882819' OR flow='1916289507' OR flow='2121958995'
OR flow='2142167604'
LIMIT 1000;
希望SQL有事数组列表,如:
MyFlows = @[1921474754, 3326882819, 1916289507, 2121958995, 2142167604]
WHERE date='2013-05-14' AND event_type='flow_started' AND @MyFlows
你应该知道它在SQL中是* not * true,AND在OR之前绑定。因此,所写的查询可能不会返回您期望的结果 - 它将包括流='2142167604',无论日期或event_type。 –
谢谢@LarryLustig。我使用了以下顶部答案中的查询:WHERE date ='2013-05-14'AND event_type ='flow_started' AND flow IN('1921474754','3326882819','1916289507','2121958995','2142167604' )这应该照顾绑定顺序问题 – user1899415