/*--按作者查詢函數(shù)--*/create function A_name_search (@Bauthor varchar(30)) returns tableas return(select Sum_Book.Bindex '索引名',Sum_Book.Bname '書(shū)名',Sum_Book.Bauthor '作者',C_book '總藏書(shū)量', C_book-C_B_Book '可借量'from Sum_Book,Count_Borrowed_Bookgroup by Sum_Book.Bindex,Sum_Book.Bname,Sum_Book.Bauthor,C_book,C_B_Bookhaving Sum_Book.Bauthor like '%'+@Bauthor+'%') go在sql server2005里面的查詢語(yǔ)句如下:select * from A_name_search('李')結(jié)果如圖:在delphi里面的語(yǔ)句如下:procedure TForm5.Button1Click(Sender: TObject);beginadoquery1.SQL.Add('select * from A_name_search(:author)'); adoquery1.Parameters.ParamByName('author').Value:=edit1.Text;adoquery1.ExecSQL;adoquery1.open;end; 結(jié)果如圖:
1 回答

一只萌萌小番薯
TA貢獻(xiàn)1795條經(jīng)驗(yàn) 獲得超7個(gè)贊
這個(gè)簡(jiǎn)單 你加一個(gè)order by Sum_Book.Bindex 排序就可以保持一致了 一般都會(huì)用到這個(gè)
- 1 回答
- 0 關(guān)注
- 93 瀏覽