and/or conditions in a SQL query

折月煮酒 提交于 2019-12-25 03:19:32

问题


I have to select all the records where FIELD1 is value11 or value12 and FIELD2 is value21, value22, value23, ... or value29. All 2*9=18 pairs of admissible values for FIELD1 and FIELD2 are possible. Which is the most compact form to write down my SQL query?


回答1:


where field1 in (value11, value12)
and field2 in (value21, value22, value23, ..., value29)

(Where you need to replace the dots with all value24 and so on.)



来源:https://stackoverflow.com/questions/3936253/and-or-conditions-in-a-sql-query

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!