Use [db_news]go/****** Object: StoredProcedure [dbo].[ Selecthotnews] Script date:2015/7/8 13:34:46 ******/set ansi_nulls ongoset quoted_identifier ONGO--============== ===============================--author:hf_ultrastrong--Create date:2015 July 5 16:40:20--Description: Remove 10 Hot news (Hot news: most commented)--=============================================alter PROCEDURE [dbo]. [Selecthotnews] Asbeginselect Top 5 n.id, N.title, N.createtime, C.name, Count (t.id) as Countnumberfrom tb_news as Ninner join Tb_category As C on n.caid = c.id--with left connection, so you can query the news that the comment is 0 on the tb_comment as T in T.newsid = N.idgroup by N.id, N.title, N.createtim E, c.nameorder by CountNumber descend
It involves up to three tables, classification tables, news sheets, and commentary tables.
Final removal effect:
MSSQL-Stored procedure remove 5 Hot News