/*--按作者查询函数--*/
create function A_name_search (@Bauthor varchar(30))
returns table
as
return(
select Sum_Book.Bindex '索引名',Sum_Book.Bname '书名',Sum_Book.Bauthor '作者',C_book '总藏书量', C_book-C_B_Book '可借量'
from Sum_Book,Count_Borrowed_Book
group by Sum_Book.Bindex,Sum_Book.Bname,Sum_Book.Bauthor,C_book,C_B_Book
having Sum_Book.Bauthor like '%'+@Bauthor+'%'
)
go
在sql server2005里面的查询语句如下:
select * from A_name_search('李')
结果如图:
在delphi里面的语句如下:
procedure TForm5.Button1Click(Sender: TObject);begin
adoquery1.SQL.Add('select * from A_name_search(:author)'); adoquery1.Parameters.ParamByName('author').Value:=edit1.Text;
adoquery1.ExecSQL;
adoquery1.open;
end;
结果如图:
一只萌萌小番薯
相关分类