22,300
社区成员




create table a_b_match(
mId int identity(1,1) primary key,
aId int not null,
bId int not null,
title nvarchar(200) not null,
[content] nvarchar(max) not null,
[keyword] nvarchar(200) not null
)
insert into a_b(aId,bId,title,[content],[keyword])
select a.id,b.id,a.title,a.[content].b.[keyword]
from a inner join b on CHARINDEX(b.keyword, a.title) > 0
OR CHARINDEX(b.keyword, a.content) > 0
在 a 上创建触发器, 增、删、改时修改 a_b_match 的记录即可。
你想查啥, 直接查 a_b_match 表就可以了, 不用再查别的表。保证你快!SELECT *
FROM a
JOIN b ON CHARINDEX(b.keyword, a.title) > 0
OR CHARINDEX(b.keyword, a.content) > 0