当前位置:数据库 > SQLServer >>

mysql语句与sqlserver语句转换

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 把这句mysql语句转换成sqlserver语句
答案:其它的应该都差不多,limit 10  改成top 10应该就可以了,大致如下:

select  top 10 * 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

上一个:sqlserver2005中,如何删除基本表中的一列
下一个:sqlServer2005已经建好a、b两张表,想把a表x,y,z字段中的值查出来,写入b表的l,m,n字段。该怎么做?

CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,