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的列