SQL【1】基础语法

真的是基础中的基础了。

目录

真的是基础中的基础了。

select列from表​编辑

[筛出不同值 select distinct 列 from表​编辑 ​编辑](#筛出不同值 select distinct 列 from表编辑 编辑)

[​编辑 select列form 表 where条件​编辑](#编辑 select列form 表 where条件编辑)

[and or​编辑](#and or编辑)

[order by](#order by)

[​编辑筛选+排序:select 列们,逗号隔开from 表 order by 列名​编辑](#编辑筛选+排序:select 列们,逗号隔开from 表 order by 列名编辑)

[优先级排序 select a,b from 表 order by a,b ​编辑](#优先级排序 select a,b from 表 order by a,b 编辑)

所以只有在第一优先级相等时,才会进入比较第二优先级​编辑

[逆序排:order by 列 desc​编辑](#逆序排:order by 列 desc编辑)

[descend下降 ascend上升](#descend下降 ascend上升)

[​编辑插入 insert into 表 values 值;insert into 列 values 值​编辑](#编辑插入 insert into 表 values 值;insert into 列 values 值编辑)

整整一行

仅填充部分数据

[insert into 表(需要添加的列名在表后括号内)values (值们)​编辑](#insert into 表(需要添加的列名在表后括号内)values (值们)编辑)

修改update

[update 表 set 列 =想改成的值 where 条件​编辑](#update 表 set 列 =想改成的值 where 条件编辑)

​编辑

修改多个列

[update 表 set 列1 =想改成的值1 ,列2 =想改成的值2 ......where 条件​编辑](#update 表 set 列1 =想改成的值1 ,列2 =想改成的值2 ……where 条件编辑)

[删除delete from------delete from 表 where 条件](#删除delete from——delete from 表 where 条件)

删除所有行,但表还在

[1.delete from 表](#1.delete from 表)

[2.delete * from 表​编辑](#2.delete * from 表编辑)


select列from表

筛出不同值 select distinct 列 from表

加了distinct后

select列form 表 where条件

等于不是==

列名='值' 表示要该项为该值

引号:文本,无需引号:数值

and or

order by

筛选+排序:select 列们,逗号隔开from 表 order by 列名

优先级排序 select a,b from 表 order by a,b

所以只有在第一优先级相等时,才会进入比较第二优先级

逆序排:order by 列 desc

默认是升序的,当然扩充下词汇量

descend下降 ascend上升

插入 insert into 表 values 值;insert into 列 values 值

值的格式:外有括号,里面用逗号隔开,不一定是整整一行

整整一行

仅填充部分数据

insert into 表(需要添加的列名在表后括号内)values (值们)

修改update

update 表 set 列 =想改成的值 where 条件

修改多个列

update 表 set 列1 =想改成的值1 ,列2 =想改成的值2 ......where 条件

删除delete from------delete from 表 where 条件

删除所有行,但表还在

1.delete from 表

2.delete * from 表

相关推荐
柯3491 分钟前
Redis的过期删除策略和内存淘汰策略
数据库·redis·lfu·lru
Tiger_shl13 分钟前
【Python语言基础】24、并发编程
java·数据库·python
林夕112021 分钟前
颠覆认知的MySQL全解析:安装、连接到SQL三大核心语句全掌握
后端·mysql
05091522 分钟前
测试基础笔记第十一天
java·数据库·笔记
A charmer40 分钟前
【MySQL】数据库基础
数据库·mysql
pjx9871 小时前
应用的“体检”与“换装”:精通Spring Boot配置管理与Actuator监控
数据库·spring boot·oracle
松树戈1 小时前
PostgreSQL 分区表——范围分区SQL实践
数据库·sql·postgresql
bing_1581 小时前
Redis 的单线程模型对微服务意味着什么?需要注意哪些潜在瓶颈?
数据库·redis·微服务
wangzhongyudie1 小时前
SQL实战:01之行转列实现
数据库·sql
斗鹰一余洛晟2 小时前
工作中sql总结
数据库·sql