热门标签 | HotTags
当前位置:  开发笔记 > 数据库 > 正文

请帮忙解释一下,多表联查,小弟我看太不懂,谢啦

请帮忙解释一下,多表联查,我看太不懂,,谢啦SQLcodeselect*from(selectbookid,count(bookid)asdegreefromtb_borrowgroupbybookid)asborrjoin(selectb.*,c.nameasbookcasename,p.pubname,t.typ
请帮忙解释一下,多表联查,我看太不懂,,谢啦
SQL code
http://www.CodeHighlighter.com/-->select * from (select bookid,count(bookid) as degree from tb_borrow group by bookid) as borr join (select b.*,c.name as bookcasename,p.pubname,t.typename from tb_bookinfo b left join tb_bookcase c on b.bookcase=c.id join tb_publishing p on b.ISBN=p.ISBN join tb_booktype t on b.typeid=t.id where b.del=0) as book on borr.bookid=book.id order by borr.degree desc limit 10 
请帮忙解释一下,多表联查,我看太不懂,,谢啦

------解决方案--------------------
SQL code
select * from     (        select bookid,count(bookid) as degree from tb_borrow group by bookid    )as borr join       (         select b.*,c.name as bookcasename,p.pubname,t.typename from tb_bookinfo b left join tb_bookcase c on b.bookcase=c.id join tb_publishing p on b.ISBN=p.ISBN join tb_booktype t on b.typeid=t.id where b.del=0      ) as book on borr.bookid=book.id order by borr.degree desc limit 10


推荐阅读
author-avatar
航19830_811
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有