SQL Like and like

前端 未结 5 1358
孤独总比滥情好
孤独总比滥情好 2020-12-11 23:07

Is it possible to string together multiple SQL LIKE wildcards in one query - something like this?

LIKE \'% aaaa %\' AND LIKE \'% bbbb %\'

T

5条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-12 00:05

    It is possible to string together an arbitrary number of conditions. However, it's prudent to use parenthesis to group the clauses to remove any ambiguity:

    SELECT *
      FROM tableName
     WHERE (columnOne LIKE '%pattern%')
       AND (columnTwo LIKE '%other%')
    

提交回复
热议问题