1.创建表
create table A (id int);
2.删除表
drop table A
3.添加数据
insert into A (id) values (1);
4.删除某一行内容
delete from A where id = 1
5.为表添加字段
alter table A add name varchar(10)
6.为表删除字段
alter table A drop name
7.查询名字为sam的人数
select count(*) from A where name = ‘sam’
8.查询学生,学生的科目数量
select name,count(subject) from A
9.查询学生,科目,成绩,先按照名字排列,再按成绩由高到低排列
SELECT name,subject,score from a ORDER BY name,score DESC
10.查询学生,成绩最高的科目,成绩(只差一条数据,即一个学生)
SELECT name,subject,max(score) from a
11.查询每个学生,成绩最高科目,成绩(每个学生)
SELECT name,subject,max(score) from a GROUP BY name
SQL语句学习
最新推荐文章于 2023-02-02 11:16:11 发布