这是来新公司写的第一篇文章,使用LEFT JOIN ON LIKE处理一下这种问题:
SQL视图代码如下:
CREATE View [dbo].[VI_SearchCN] AS --搜索产品的文件 ( select upload.FileId as ID,upload.Name as Title,upload.Name as FileTxt,con.TypeId as TypeId,upload.Path as DownLoadPath, '文件' as SearchType,'0' as CategoryId,'0' as ParentCategoryId,upload.Sort,upload.CreateDate from Whir_Ext_Upload upload left join Whir_U_Content con on ('*'+con.FileDownload+'*') like ('%*'+upload.Path+'*%') where con.FileDownload!='' and con.IsDel=0 and con.TypeId=2 ) UNION ALL --搜索产品 ( select con.Whir_U_Content_PId as ID,con.Title,