--建立函数
create function fn_Getauthors(@book varchar(20))
returns varchar(200)
as
begin
   declare @r varchar(200)
   set @r=''
   select @r=@r+','+rtrim(author) from tab2 where book=@book
   if @r<>'' set @r=right(@r,len(@r)-1)
   return @r
end
go--查询
select *,dbo.fn_Getauthors(book) as author from tab1
where exists (
select 1 from tab2 where book=tab1.book
)