【发布时间】:2015-09-14 17:27:10
【问题描述】:
我想对两个表进行 LIKE 搜索。一个表有一列搜索词,另一表具有执行 LIKE 搜索的列。以下是表格:
create table #TableA
(
UserName Varchar(50)
)
create table #TableB
(
Department Varchar(50),
Keyword Varchar(50)
)
Insert Into #TableA VALUES('bob_sales')
Insert Into #TableA VALUES('mary_accounting')
Insert Into #TableA VALUES('sammi_accountant')
Insert Into #TableA VALUES('fred_bestSellerEver123')
Insert Into #TableB VALUES('Accounting', 'accounting')
Insert Into #TableB VALUES('Accounting', 'accountant')
Insert Into #TableB VALUES('Sales', 'sales')
Insert Into #TableB VALUES('Sales', 'seller')
我想运行一个使用 LIKE %keyword% 的查询并给我:
bob_sales | Sales
mary_accounting | Accounting
sammi_accountant | Accounting
fred_bestSellerEver123 | Sales
【问题讨论】:
-
是某种数据清理吗?
-
这是为了能够根据将数据与各个部门相关联的关键字术语对大量数据进行分类
标签: join sql-server-2012