最近常用的sql语句

来源:互联网 发布:图书馆软件知乎 编辑:程序博客网 时间:2024/05/16 14:14
use cms
go
---进入cms数据库--


--查询数据库里状态为已签发和插入时间为当前时间前24小时以内的文章--
select * from cms_article where status='4' and DateDiff(hh,insertedTime,getDate())<=24



--返回查询条数,查询指定时间以前的文章--
select count (*) as rownum from cms_article where status='4' and insertedTime<'2009-12-24' 



---更新时间为系统当前时间,指定的文章把时间更新--

update cms_article set insertedTime =getDate() where insertedTime< '2009-12-24' 


--双表查询,查询结果插入到另一张表中--

insert into cms_addURLContentSeo(id,keywords,url,insertedTime) select a.id as id,a.[name] as keywords,b.website as url,a.insertedtime as insertedTime from cms_category as a join cms_corp as b on a.id=b.id 


--删除url为空的--

delete from cms_addURLContentSeo where url=''

0 0
原创粉丝点击