SQL语句

select *from student; (列的顺序,是按照建表的时候排列的)
select name,sex from student;

select sname,2016-age as”year of birth” from s;
注意:列可以是表达式 as<别名>,在显示列名的时候 变会以别名来显示。as有时候可以省略

消除取值重复的行
原始的:select sdept from s;
改变后为:select distinct sdept from s;

(比较范围)
select age from s where age<22;

(确定集合)
between and 语句
select name,age from s where age between 20 and 25;

(查询条数)
select count(distinct name)from student
select count(*)from student

求平均数
select AVG(age) from student;

删除数据
delete from student where age<20

修改数据
update student set name=”xiaoming” where name=”xiaogou”

插入数据
insert into student values(“xiaoming”,”male”,24)

对查询结果进行排序
select age from student order by age

删除表
drop table student

创建表
create table student
{
id int ,
name char(20)

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值