MySQL LIKE IN()?

后端 未结 11 1699
时光说笑
时光说笑 2020-11-22 05:31

My current query looks like this:

SELECT * FROM fiberbox f WHERE f.fiberBox LIKE \'%1740 %\' OR f.fiberBox LIKE \'%1938 %\' OR f.fiberBox LIKE \'%1940 %\'
         


        
11条回答
  •  别跟我提以往
    2020-11-22 06:05

    Just note to anyone trying the REGEXP to use "LIKE IN" functionality.

    IN allows you to do:

    field IN (
    'val1',
    'val2',
    'val3'
    )
    

    In REGEXP this won't work

    REGEXP '
    val1$|
    val2$|
    val3$
    '
    

    It has to be in one line like this:

    REGEXP 'val1$|val2$|val3$'
    

提交回复
热议问题