当前位置:网站首页>MySQL addition, deletion, query and modification (primary level)
MySQL addition, deletion, query and modification (primary level)
2022-06-26 03:29:00 【Acquaintance-】
List of articles
MySQL Add, delete, check and modify the primary level
stay MySQL The annotation method in
We can use – perhaps ## stay MySQL Implementation notes in
1. insert data
1.1 Single line input + Insert all columns
– Insert a record ,value_list The number must be consistent with the number and order of the columns that define the table
insert into Table name values( data , data …)
1.2 Multi row data + Specify column insertion
– Insert two records ,value_list The quantity must be consistent with the number and order of the specified columns
Suppose our student Table has id name and score
insert into student(id,name) values (1,‘ Xiao Wang ’),(2,‘ petty thief ’)
3. Inquire about
3.1 Full column query
select * from Table name
View all table data contents ( * The wildcard , Just use * Instead of column names, you can query all columns ) This operation is dangerous , For example, the amount of data is too large
1. Memory full , Cause crash
2.MySQL The server will read the hard disk crazily , Full hard disk IO bandwidth , then MYSQL The server's return to the client will occupy the full network bandwidth )
3.2 Specified column query
select Name , Name from Table name
3.3 The query field is an expression
Form like :
– The expression does not contain fields
select id, name, 10 from student;
– The expression contains a field
select id, name, english + 10 from student;
– The expression contains multiple fields
select id, name, chinese + math + english from student;
3.4 Alias (as)
Name [as] Alias (as It can be omitted )
Such as
– Result set , The column name of the header = Alias
select id, name, chinese + math + english [as] Total score from student;
3.5 duplicate removal (distinct)
When there are duplicates in the data , We can go through distinct To get a result after weight removal
select distinct Name from Table name
3.6 Sort (order by)
Sorting by a benchmark
select Name (*)… from Table name order by Name asc( Ascending )/desc( Descending ) If you omit and do not write, it is the default ascending order , If there is... In the record NULL,NULL Think it's the smallest It is to sort by a certain column among many columns
Sorting by multiple benchmark values
select Name (*)… from Table name order by Name … asc( Ascending )/desc( Descending ) That is to say, in a certain number of columns ( Priority exists ) Sort by benchmark
3.7 Conditions of the query (where)
1. Comparison operator
Operator | explain |
---|---|
>, >=, <, <= | Greater than , Greater than or equal to , Less than , Less than or equal to |
= | be equal to ,NULL unsafe , for example NULL = NULL The result is NULL |
<=> | be equal to , NULL Security , for example NULL <=> NULL The result is TRUE(1) |
!=, <> | It's not equal to |
between a0 and a1 | Range match , [a0, a1], If a0 <= value <= a1, return TRUE(1) |
in (option, …) | If it is option Any one of , return TRUE(1) |
is NULL | yes NULL |
is not NULL | No NULL |
like | Fuzzy matching . % Denotes any number of ( Include 0 individual ) Any character ; _ Represents any character |
2. Logical operators
Operator | explain |
---|---|
and | Logic and More than one condition must be TRUE(1), The result is TRUE(1) |
or | Logic or Any one of the conditions is TRUE(1), The result is TRUE(1) |
not | Logic reverses Condition is TRUE(1), The result is FALSE(0) |
4. Paging query (limit)
– from 0 Start , Screening n Bar result
select … from table_name [where …] [order by …] limit n;
– from s Start , Screening n Bar result
select … from table_name [where …] [order by …] limit s, n;
– from s Start , Screening n Bar result , Than where This usage is more specific , It is recommended to use
select … from table_name [where …] [order by …] limit n offset s;
5. modify (Update)
update [ Table name ] set [ Name ] = [ Modified value ], [ Name ] = [ Modified value ] where Clause ;
6. Delete (delete)
delete from [ Table name ] where [ filter ];
边栏推荐
- Analysis and optimization of ue5 global illumination system lumen
- 【论文笔记】Supersizing Self-supervision: Learning to Grasp from 50K Tries and 700 Robot Hours
- Xiaomi TV's web page and jewelry's web page
- [QT] custom control - switch
- ArrayList#subList这四个坑,一不小心就中招
- Classic quotations from "human nature you must not know"
- 指南针app是正规的吗?到底安不安全
- Review of the paper: unmixing based soft color segmentation for image manipulation
- Group note data representation and operation check code
- progress bar
猜你喜欢
浅谈虚拟内存与项目开发中的OOM问题
MySQL development environment
Types and application methods of screen printing
经典模型——NiN&GoogLeNet
Click event
Graphics card, GPU, CPU, CUDA, video memory, rtx/gtx and viewing mode
Qt编译出错ERROR: Unknown module(s) in QT: script
Google recommends using kotlin flow in MVVM architecture
ArrayList#subList这四个坑,一不小心就中招
给网站添加“开放搜索描述“以适配浏览器的“站点搜索“
随机推荐
Insect structure and Deconstruction
2021-08-04
Partition, column, list
[QT] custom control - air quality dashboard
Hardware creation principle of campus maker space
在哪里开基金帐户安全?
Class diagram
scrapy返回400
Golang regexp package use - 06 - other usage (Special Character conversion, find regular Common prefix, Switch gourmand mode, query regular Group NUMBER, query regular Group name, cut with regular, qu
【论文笔记】Manufacturing Control in Job Shop Environments with Reinforcement Learning
[QT] custom control - switch
HL7Exception: Can‘t XML-encode a GenericMessage. Message must have a recognized struct
【哈希表】改进,拉链法哈希结构——直接用两个索引查找,不用每次都hash和%一遍
上传文件/文本/图片,盒子阴影
云计算基础-0
用元分析法驱动教育机器人的发展
[hash table] a very simple zipper hash structure, so that the effect is too poor, there are too many conflicts, and the linked list is too long
XGBoost, lightGBM, CatBoost——尝试站在巨人的肩膀上
The "eye" of industrial robot -- machine vision
Kotlin quick start