日期:2014-05-18 浏览次数:20670 次
select * from table2 a left join table1 b on charindex(a.KEYWORD,b.TITLE )>0 order by a.CRTDATE-getdate()
------解决方案--------------------
select m.title, m.content, m.crtdate, n.keyword, n.holdday,
priority = case when datediff(day, getdate(), n.CRTDATE) > n.holdday then '' else n.priority end
from
(select * from table2) m
cross apply
(
select top(1) *
from table1 a
inner join table2 b
on b.title like '%'+a.keyword+'%' or b.content like '%'+a.keyword+'%'
where b.title = m.title and b.content = m.coneten and b.crtdate = m.crtdate
order by a.priority
) n
------解决方案--------------------