您的位置:首页 > 产品设计 > UI/UE

数据库——SQL语句(Structured query Language)

2012-07-24 11:47 323 查看
sql查询

查询:Select 【predicate】字段列表 from 表的列表(可以是多个表)

注:predicate的选取:1.all,返回所有满足条件的记录

2.Distinct,返回不同的记录

3.distinctrow,(对于整体都不一样,比上面的更严格根据行来判断)

4.top n,可能很多条件满足,只显示指定的前n行

选取:where 选取的条件

分组:Group by 条件 //(按选取的条件分组)

排序:order by 条件 asc(缺省情况下按升序排序)【desc降序】 //将分组的内容排序,将结果排序输出

常见的格式:例如有一个关于学生信息的数据表。

select * from *

where student age>20

order by name desc



sql 命令

更新一个表:update

删除一个表:delete

插入一个表:insert



例子:

Select count(*) from student where speciality=”数信学院” and age>22

Group by sex having sex=”男” order by age desc

Update student set age=24 where name=”张三”

Delete from student where age>25
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: