对 1 个变量具有多个 LIKE 的 SQL [英] SQL with multiple LIKEs over 1 variable

查看:52
本文介绍了对 1 个变量具有多个 LIKE 的 SQL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

SELECT *
FROM company_address
WHERE address_telephone LIKE '%12%'
AND address_telephone LIKE '%45%' (edit)

小问题:有没有办法只使用一次列名?

Short question: Is there a way to only use the column name once?

(这是一个例子,抱歉……)

(edit: It was an example, sorry for that.. )

推荐答案

简短回答:否

旁注:我不知道您的查询业务规则,但看起来您可能希望使用 OR 而不是 AND.

Side note: I do not know your business rules for the query, but it looks like you might want to be using OR instead of AND.

长答案:如果是等式,你可以使用IN.但是,由于您使用的是 LIKE,您必须指定每个 LIKE 条件.

Long answer: If it was an equality, you could use IN. However, since you are using LIKE, you have to specify each LIKE condition.

这篇关于对 1 个变量具有多个 LIKE 的 SQL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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