SQL:在子字符串上连接表 [英] SQL: Join tables on substrings

查看:25
本文介绍了SQL:在子字符串上连接表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个表 A 带有字符串列 a 和一个表 B 带有字符串列 b.a 是 b 的子串.现在我想加入 a 和 b 上的两个表.这可能吗?

I have a table A with the string-column a and a table B with the string-column b. a is a substring of b. Now I want to join the the two tables on a and b. Is this possible?

我想要这样的东西:

Select * from A,B where A.a *"is substring of"* B.b

如何在 SQL (Transact-SQL) 中编写它?

How can I write this in SQL (Transact-SQL)?

推荐答案

您可以使用 喜欢

select *
from A
  inner join B 
    on B.b like '%'+A.a+'%'

这篇关于SQL:在子字符串上连接表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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