postgres syntax question for OR?
Posted
by Dashiell0415
on Stack Overflow
See other posts from Stack Overflow
or by Dashiell0415
Published on 2010-05-30T14:48:14Z
Indexed on
2010/05/30
14:52 UTC
Read the original article
Hit count: 149
The first one below works, but, just wanted to see if there's a better way...
If I'm trying to find all records that start with 'C' with either a flag of 2 or a status of 9, do I need to incorporate the 'C' criteria twice?
i.e.,
"SELECT * FROM mytable WHERE name like 'C%' AND flag = 2 OR name like 'C%' AND status = 9"
Or, is there a way quicker way to write it so that I only need to set 'C%' once?
© Stack Overflow or respective owner