快速学习,理解.SQL注入技术
2008-10-27 16:51:19 来源:WEB开发网e.[]匹配检查符:select * from courses where cno like '[AC]%' (表示或的关系,与"in(...)"类似,而且"[]"可以表示范围,如:select * from courses where cno like '[A-C]%')
3.对于时间类型变量的处理
a.smalldatetime:直接按照字符串处理的方式进行处理,例如:select * from students where birth > = '1980-1-1' and birth <= '1980-12-31'
4.集函数
a.count()求和,如:select count(*) from students (求学生总人数)
b.avg(列)求平均,如:select avg(mark) from grades where cno=’B2’
c.max(列)和min(列),求最大与最小
5.分组group
常用于统计时,如分组查总数:select gender,count(sno) from students group by gender(查看男女学生各有多少)
注意:从哪种角度分组就从哪列"group by"
对于多重分组,只需将分组规则罗列。比如查询各届各专业的男女同学人数 ,那么分组规则有:届别(grade)、专业(mno)和
性别(gender),所以有"group by grade, mno, gender"
select grade, mno, gender, count(*) from students group by grade, mno, gender
通常group还和having联用,比如查询1门课以上不及格的学生,则按学号(sno)分类有:
select sno,count(*) from grades where mark<60 group by sno having count(*)>1
6.UNION联合
合并查询结果,如:
SELECT * FROM students WHERE name like ‘张%’UNION [ALL] SELECT * FROM students WHERE name like ‘李%’
更多精彩
赞助商链接