sql指令,增,删,查,改
- 2021 年 4 月 28 日
- 笔记
增
insert into table (name,sex,age) value(‘张三’,‘男’,‘20’) 向表中的name,sex,age,分别添加张三,男,20的内容
查
select “要查找的东西” from “从哪一个表查” *代表所有
select name where table where name=’肖淇’ 在表中查询名字为肖淇的内容
删
delete from table where name=’肖淇’ 在表中删除名字为肖淇的内容
delete from table 删除整个表中的内容
改
update table name=’张三’ where name=’肖淇’ 将表中名字为肖淇的内容改为张三
拓展:
排序
select * from table order by age 查询表中所有信息,并按年级升序排序
select * from table order by age desc 查询表中所有信息,并按年级降序排序
返回唯一不同的值
select distinct age from table 查询表中不同的年龄有那些
and ,or
select * from table where sex=’男’ and age>20 查询表中性别为男并且年龄大于20的列
select * from table where sex=’女’ or age>20 查询表中性别为女或者年龄大于20的列