当前位置:网站首页>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,一定要小心谨慎
边栏推荐
- ofstream,ifstream,fstream read and write files
- swift项目,sqlcipher3 -&gt; 4,无法打开旧版数据库有办法解决吗
- 垃圾回收器CMS和G1
- "NetEase Internship" Weekly Diary (1)
- swift project, sqlcipher3 -> 4, cannot open legacy database is there a way to fix it
- Huawei's 5-year female test engineer resigns: what a painful realization...
- Win Go开发包安装配置、GoLand配置
- 3. Bean scope and life cycle
- [ORB_SLAM2] void Frame::ComputeImageBounds(const cv::Mat & imLeft)
- "NetEase Internship" Weekly Diary (2)
猜你喜欢
Constructor of typescript35-class
【LeetCode每日一题】——654.最大二叉树
Redis 订阅与 Redis Stream
Golang分布式应用之定时任务
Power button 1374. Generate each character string is an odd number
Win Go development kit installation configuration, GoLand configuration
Software testing Interface automation testing Pytest framework encapsulates requests library Encapsulates unified request and multiple base path processing Interface association encapsulation Test cas
"NetEase Internship" Weekly Diary (1)
雇用WordPress开发人员:4个实用的方法
Use baidu EasyDL implement factory workers smoking behavior recognition
随机推荐
垃圾回收器CMS和G1
Win Go开发包安装配置、GoLand配置
Yunhe Enmo: Let the value of the commercial database era continue to prosper in the openGauss ecosystem
A good book for newcomers to the workplace
CodeTon Round 2 D. Magical Array
Coding Experience Talk
Simple example of libcurl accessing url saved as file
Redis for distributed applications in Golang
typescript33 - high-level overview of typescript
PHP uses PHPRedis and Predis
Constructor instance method of typescript36-class
HSDC is related to Independent Spanning Tree
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
The ultra-large-scale industrial practical semantic segmentation dataset PSSL and pre-training model are open source!
3. Bean scope and life cycle
Rasa 3.x 学习系列- Rasa - Issues 4873 dispatcher.utter_message 学习笔记
2022-08-01 反思
2022-08-01 Reflection
Named parameter implementation of JDBC PreparedStatement
LeetCode刷题日记:34、 在排序数组中查找元素的第一个和最后一个位置