SQL中以日期为条件统计方法
/*统计每天数据总量三种方法:
select convert(char(10),happentime ,120) as date ,count(1) from table1
group by convert(char(10),happentime ,120) order by date desc
select day(happentime) as date,count(*) from table1
group by day(happentime) order by date desc
SELECT left([happentime],5),count (1)
from [database].[dbo].[ table1]
group by left([happentime],5)
order by left([happentime],5)
说明:happentime为表字段名;
大家分别测试下 left([happentime],20) 与 convert(char(10),happentime ,120) 、day(happentime) 两者的区别,对于新人来说,从left([happentime],5) 来看结果往往看不出来与其他两个的不同。
如果不明白语句如何写,请参考如下:
select convert(char(10),happentime ,120) from table1
SELECT left([happentime],5) from table1
SELECT left([happentime],5) from table1
相关文档:
--SQL 截取字符串方法,中文算两个字符的方法。
--方法跟水哥学习的,支持一下水哥的博客
--http://hi.csdn.net/link.php?url=http://blog.csdn.net%2Fwufeng4552
--水哥最近谢了好多博客,有时间一定去好好学习
--LEFT() 和SUBSTRING()都是将汉字算一个字符来算的
--如果不计较的话,推荐使用这两个系统函数
IF OBJE ......
SQL重复记录查询
1、查找表中多余的重复记录,重复记录是根据单个字段(peopleId)来判断
select * from
people
where peopleId in (select peopleId from people group by peopleId
having count
(peopleId) > 1)
2、删除表中多余的重复记录,重复记录是根据单个字段(p ......
没有引用关系的表
1. 联表更新
update a set a.education = '本科' from NT_UserInfo a ,NT_User b where a.UserID=b.UserID and b.email = 'carlfan2008@163.com'
2. 联表查询
select a.*,b.* from nt_user as a, nt_userinfo as b where a.userid = b.userid and Email = 'carlfan2008@163.com ......
引自http://www.05112.com/Article/200908/26674.html
网站SQL注入漏洞全接触(高级篇)
文章整理发布:黑客风云 内容关注度:
291 更新时间:2009-8-15 6:36:47
看完入门篇和进阶篇后,稍加练习,破解一般的网站是没问题了。但如果碰到表名列名猜不到,或程序作者过滤了一些特殊字符,怎么提高注入的成功率?怎 ......
[C#]
public void RunSqlTransaction(string myConnString)
{
SqlConnection myConnection = new SqlConnection(myConnString);
myConnection.Open();
SqlCommand myCommand = myConnection.CreateCommand();
SqlTransaction m ......