如何将LIKE语句与另一个字段中的多个值一起使用? [英] How to use LIKE statement with multiple values from another field?

查看:146
本文介绍了如何将LIKE语句与另一个字段中的多个值一起使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想选择所有记录,其中字段包含来自另一个字段的值。我怎么做?这是我正在尝试的代码。

I want to select all records where field contains values from another field. How do I do that? Here is a code that I am trying.

select field1 , field2, field3 
from table1
where field1 like '%'+(select distinct field4 from table2)+'%'

< br>
预先感谢。


Thanks in advance.

推荐答案

只需做一个喜欢的加入条件:

Just do your like as a join condition:

select field1 , field2, field3 
from table1
join (select distinct field4 from table2) x
  on field1 like '%'+field4+'%'

这篇关于如何将LIKE语句与另一个字段中的多个值一起使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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