SQL:如何从 CTE 中选择至少一个类似的值

发布于 2025-01-13 18:35:24 字数 8 浏览 1 评论 0原文

continue

I created a CTE of distinct string values and I want to select from dataset only values (strings) that contains at least one of strings from the CTE.
I need some kind of in multiple like from CTE.

Example:

say we have @data_1, @data_2 and CTE

with CTE as (
select distinct words
from @data_1
)

I want to select only values from @data_2 that contains at least one of the words in the CTE.

if CTE contains:
'one',
'two',
'three'

and @data_2 contains: 'one hundred', 'two thousend', 'thirty'

SELECT only the values- 'one hundred', 'two thousend'

Is there a way to do that (with use of CTE and not LIKE singular values)?
Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

瑾夏年华 2025-01-20 18:35:24

continue

You can write

WHERE table_column_name = CTE_column_name

NB: if there were duplicates in the CTE this would return duplicate rows.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文