'LIKE('%this%'或'%that%')和其他东西不起作用 [英] 'LIKE ('%this%' OR '%that%') and something=else' not working

查看:62
本文介绍了'LIKE('%this%'或'%that%')和其他东西不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个选择查询,我试图在其中搜索多种模式的字符串

I have a select query where I am trying to search strings for multiple patterns

LIKE ('%this%' or '%that%' ) and something=else

返回零结果

但是

LIKE '%this%' and something=else

返回结果 和

LIKE '%that%' and something=else

返回结果

是否有可能将我所有的结果纳入一个查询?如果一个字符串匹配两者,它将如何处理?

Is it possible to get all my results into one query? If a string matches both, how will it handle that?

推荐答案

如果可以的话,这很好,但是您不能在SQL中使用该语法.

It would be nice if you could, but you can't use that syntax in SQL.

尝试一下:

(column1 LIKE '%this%' OR column1 LIKE '%that%') AND something = else

请注意使用括号!您需要在OR表达式周围.
如果没有括号,它将被解析为A OR (B AND C),不会为您提供预期的结果.

Note the use of brackets! You need them around the OR expression.
Without brackets, it will be parsed as A OR (B AND C),which won't give you the results you expect.

这篇关于'LIKE('%this%'或'%that%')和其他东西不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆