我如何加入2个具有相似但不完全相同的值的表?

发布于 2025-01-28 05:15:36 字数 522 浏览 1 评论 0原文

我有2个表,我试图在“程序”列(以及其他)上加入。 问题是程序名称并不完全相同 - 但是它们相似。

一个表格可能具有

program1
program2
program3

另一个表的地方可能具有:

xyz-program1-highlights
z-program1-extra
abc-program1
123-program2
3-program2
A-program3 

或其对基本上的任何变化

,可以从基本上做一个类似命令来查找table1像table2并加入它们的位置?

我已经尝试过

table1 LEFT JOIN table2 
ON table1.program LIKE '%'||table2.program||'%' 

(及其一些变化),并且仅与一个程序(在大约30个)中匹配,

以防这很重要,Table2是具有联合视图的视图。

感谢您的帮助!

I have 2 tables that I'm trying to join on the 'program' column (and others).
The issue is that the program names aren't exactly the same-- they're similar though.

Where one tables may have

program1
program2
program3

The other table may have:

xyz-program1-highlights
z-program1-extra
abc-program1
123-program2
3-program2
A-program3 

or any variation thereof

Is there a way to basically do a LIKE command to find where table1 is LIKE table2 and join them?

I've tried

table1 LEFT JOIN table2 
ON table1.program LIKE '%'||table2.program||'%' 

(and some variations thereof) and it only matched one program (out of about 30)

In case this matters, table2 is a view with unioned views.

Thanks for any help!

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

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

发布评论

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

评论(1

巡山小妖精 2025-02-04 05:15:36

您可以尝试

table1  join table2 on table1.program  LIKE '%' || table.program|| '%'

link 可能会帮助您

You can try

table1  join table2 on table1.program  LIKE '%' || table.program|| '%'

This link might help you

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