Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL simple AND alternative?

Tags:

sql

extreme newbie at SQL here. Is there a simpler way to do this?

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;

Was hoping SQL has something array list like:

MyFlows = @[1921474754, 3326882819, 1916289507, 2121958995, 2142167604]
WHERE date='2013-05-14' AND event_type='flow_started' AND @MyFlows
like image 767
user1899415 Avatar asked Feb 11 '26 12:02

user1899415


1 Answers

You can use the IN keyword:

SELECT event_type, flow, userid
FROM checkpoints_esc 
WHERE date='2013-05-14' AND event_type='flow_started'
AND flow IN ('1921474754', '3326882819', '1916289507', '2121958995', '2142167604')
LIMIT 1000;
like image 192
Justin Helgerson Avatar answered Feb 13 '26 09:02

Justin Helgerson



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!