-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date,,>
-- Description: 修改新闻
-- =============================================
ALTER PROCEDURE [dbo].[news_UpdateByID]
@newsName varchar(100),
@classID int,
@newsContent text,
@newsID int
AS
BEGIN
update news set newsName='@newsName',classID='@classID',newsContent='@newsContent',addTime=getdate() where newsID='@newsID'
END
-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date,,>
-- Description: 取出10条热点新闻
-- =============================================
ALTER PROCEDURE [dbo].[news_SelectHotNews]
AS
BEGIN
select top 10 nc.className,n.newsName,n.addTime,n.newsID,n.classID,count(*) as comComment
from news n left join newsClass nc
on n.classID=nc.classID
inner join Comment com
on n.newsID=com.newsID
group by nc.className,n.newsName,n.addTime,n.newsID,n.classID
order by count(*) desc
END
-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date,,>
-- Description: 根据新闻ID取出该条新闻的主体内容
-- =============================================
ALTER PROCEDURE [dbo].[news_SelectByNewsID]
@newsID int
as
BEGIN
select *
from news n
where n.newsID=@newsID
order by addTime desc
END
-- Author: <Author,,Name>
-- Create date: <Create Date,,>
-- Description: 根据新闻ID添加评论
-- =============================================
ALTER PROCEDURE [dbo].[Comment_InsertByID]
@newsID int,
@comContent text,
@ip varchar(50)
AS
BEGIN
insert comment values('@newsID','@comContent',getdate(),'@ip')
END