当前位置:网站首页>MySQL - CRUD operations
MySQL - CRUD operations
2022-08-02 02:12:00 【Xiaolock830】
增
That is, a new row is added to the selected table in the database
全部插入
insert into 表名 values(值1,值2 ...);
Insert selected columns
insert into 表名(指定列名1, 指定列名2...) values(值1, 值2...);
删
That is, delete a row from the selected table in the database
delete from 表名;
我们可以用whereKeywords to filter the condition of the column we want to delete
delete from 表名 where 条件;
需要注意的是,在MySQL中,Our logical operator sumJava与CLanguage is different,Some common situations are listed below.
操作符含义
运算符 | 含义 |
---|---|
> ,>=,<,<= | Consistent with normal logic |
= | 和C语言不同,MySQLIn the judgment of equality, use single equals |
<=> | Determine whether both sides arenull,都为null返回true |
!=, <> | 不等于 |
between a and b | 判断是否在>= a , <= b的范围内 |
in(a , b, c…) | 判断是否为a,b,c中的一个 |
is null | 判断是否为null,是则返回ture |
is not null | 判断是否为null,是则返回false |
like | 模糊查询,%表示·多个字符,_表示单个字符 |
and | 相当于&& |
or | 相当于|| |
not | 相当于~ |
查
select 查询范围 form 表名;
We can use it in the query scope position*,It means that we want to query all the data
select * form 表名;
同样的,我们也可以用whereto filter our query criteria
select * form 表名 where 筛选条件;
去重
我们可以用distinctkeyword to deduplicate the query results
select distinct 查询范围 from 表名;
排序
我们可以用order by关键字来对查询结果进行排序
升序
select 查询范围 from 表名 order by asc;
降序
select 查询范围 from 表名 order by desc;
别名
We can alias query results
select header expression 别名 from 表名;
分页
When our query data volume is too large,We can query page by page like a browser
使用关键字limit
select * from 表名 limit Limit the number of displays;
我们用offset进行翻页,The default first page offset is 0
select * from 表命 limit Limit the number of displays offset 偏移量;
改
update 表名 set 表头 = 表达式 where 条件;
需要注意的是,Our data operations are very dangerous,一定要小心谨慎
边栏推荐
- 2022-08-01 安装mysql监控工具phhMyAdmin
- 【Unity入门计划】2D Game Kit:初步了解2D游戏组成
- nacos启动报错,已配置数据库,单机启动
- Day115.尚医通:后台用户管理:用户锁定解锁、详情、认证列表审批
- LeetCode刷题日记:53、最大子数组和
- MySQL8 下载、启动、配置、验证
- Ask God to answer, how should this kind of sql be written?
- Pinduoduo leverages the consumer expo to promote the upgrading of domestic agricultural products brands and keep pace with international high-quality agricultural products
- typescript30-any类型
- NIO‘s Sword(牛客多校赛)
猜你喜欢
Fundamentals of Cryptography: X.690 and Corresponding BER CER DER Encodings
拼多多借力消博会推动国内农产品品牌升级 看齐国际精品农货
The first time I wrote a programming interview question for Niu Ke: input a string and return the letter with the most occurrences of the string
『网易实习』周记(三)
Golang分布式应用之定时任务
2023年起,这些地区软考成绩低于45分也能拿证
typescript30 - any type
Constructor of typescript35-class
Redis 订阅与 Redis Stream
Constructor instance method inheritance of typescript37-class (extends)
随机推荐
From 2023 onwards, these regions will be able to obtain a certificate with a score lower than 45 in the soft examination.
2023年起,这些地区软考成绩低于45分也能拿证
Day115.尚医通:后台用户管理:用户锁定解锁、详情、认证列表审批
C语言之插入字符简单练习
Ringtone 1161. Maximum In-Layer Elements and
密码学的基础:X.690和对应的BER CER DER编码
Safety (2)
2022-07-30 mysql8 executes slow SQL-Q17 analysis
【ORB_SLAM2】void Frame::AssignFeaturesToGrid()
AOF rewrite
2022-07-30 mysql8执行慢SQL-Q17分析
待读书单列表
2022-08-01 安装mysql监控工具phhMyAdmin
LeetCode Review Diary: 153. Find the Minimum Value in a Rotated Sort Array
哈希冲突和一致性哈希
2022-08-01 Install mysql monitoring tool phhMyAdmin
Typescript31 - any type
[Server data recovery] Data recovery case of server Raid5 array mdisk disk offline
oracle query scan full table and walk index
openGauss切换后state状态显示不对