sql语句:
sqlStr="select MainTable.bookid,MainTable.bookname,bookwriter,pulisher,publicationDate,category,amount,ISNULL(SubTable.SubNum,0)
as amount2 from booktable as MainTable
left join (select bookid,count(1) as SubNum from borrowrecords group by bookid)as SubTable
on MainTable.bookid=SubTable.bookid";
booktable
borrowrecords:
是通过查询解决的。