当前位置:网站首页>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 ];
边栏推荐
- Click event
- 多媒体元素,音频、视频
- Qixia fire department carries out fire safety training on construction site
- 计组笔记 数据表示与运算 校验码部分
- 网络PXE启动WinPE,支持UEFI和LEGACY引导
- 【论文笔记】Deep Reinforcement Learning Control of Hand-Eye Coordination with a Software Retina
- Drawing structure diagram with idea
- [QT] custom control - air quality dashboard
- 【QT】自定义控件-空气质量仪表盘
- 工业机器人之“慧眼”——机器视觉
猜你喜欢

Vulhub replicate an ActiveMQ

Network PXE starts winpe and supports UEFI and legacy boot

Components and routing

经典模型——NiN&GoogLeNet

【论文笔记】Supersizing Self-supervision: Learning to Grasp from 50K Tries and 700 Robot Hours

拖放

Deletelater Usage Summary in QT

Drag and drop

给网站添加“开放搜索描述“以适配浏览器的“站点搜索“

Cloud Computing Foundation -0
随机推荐
用元分析法驱动教育机器人的发展
路由跳轉之點擊列錶的操作按鈕,跳轉至另一個菜單頁面並激活相應的菜單
Where is it safe to open a fund account?
Clion项目中运行多个main函数
stm32Cubemx:看门狗------独立看门狗和窗口看门狗
Please advise tonghuashun which securities firm to choose for opening an account? Is it safe to open an account online?
Kotlin quick start
Is it safe to open an online stock account?
ArrayList#subList这四个坑,一不小心就中招
Xiaomi TV's web page and jewelry's web page
请求对象,发送请求
Network PXE starts winpe and supports UEFI and legacy boot
工作室第3次HarmonyOS培训笔记
Class diagram
经典模型——NiN&GoogLeNet
【QT】自定义控件-开关
Preparation for wechat applet development
上传文件/文本/图片,盒子阴影
USB driver -debug
QT compilation error: unknown module (s) in qt: script











