SQL Multiple LIKE Statements

后端 未结 3 1463
夕颜
夕颜 2020-12-11 04:22

I\'m currently working on a report that shows me all post codes covered by our sales team.

Each team covers over 100 post codes. What i would like to do is create a

3条回答
  •  猫巷女王i
    2020-12-11 04:52

    Most of your likes are already covered by other likes. You can use likes with multiple values like this and get the same result:

    SELECT * FROM tbl_ClientFile
    WHERE 
      CLNTPOST1 LIKE ('B79%')
      OR CLNTPOST1 LIKE ('BB[12345689]%')
      OR CLNTPOST1 LIKE ('BD[1-6]%')
    

    If you check for CLNTPOST1 is like BB1%, then you don't have to check for BB11% OR BB12%

提交回复
热议问题