当前位置:网站首页>MySQL addition, deletion, query and modification
MySQL addition, deletion, query and modification
2022-07-20 22:39:00 【Midsummer Yangguang】
List of articles
1. Insert data into the table
The known table is shown in the figure :
1.1 Single row data insertion
blog.csdnimg.cn/14d8488f1cc44d52b555b1e2888f02e2.png)
Insert a piece of data in the product table : The name is “ Schoolbag ”、 Price 18.91、 stock 101、 Description is empty
insert into goods values(‘ Schoolbag ’,18.91,101,null);
1.2 Multi row data insertion
insert into goods values(‘ The bed ’,500.99,200,null),(‘ Table ’,200.99,100,null);
1.3 Specify column insertion
Insert a piece of data in the product table : The name is “ laptop ”、 Price 6566.99.
insert into goods(name,price) values(‘ laptop ’,6566.99);
2. Query the data in the table
2.1 Look up all the data in the table
select * from goods;
2.2 Specified condition query (where)
Comparison operator :
Operator | explain |
---|---|
>, >=, <, <= | Greater than , Greater than or equal to , Less than , Less than or equal to |
<=> | be equal to ,NULL Security , for example NULL <=> NULL The result is TRUE(1) |
BETWEEN a0 AND a1 | Range match ,[a0, a1], If a0 <= value <= a1, return TRUE(1) |
LIKE | Fuzzy matching .% Denotes any number of ( Include 0 individual ) Any character ;_ Represents any character |
Logical operators :
Operator | explain |
---|---|
AND | More than one condition must be TRUE(1), The result is TRUE(1 |
OR | Any one of the conditions is TRUE(1), The result is TRUE(1) |
NOT | Condition is TRUE(1), The result is FALSE(0) |
2AND Has a higher priority than OR, When used at the same time , You need to use parentheses () The priority part of the package
student In the student list , Field has name name, Age age, Ask for the surname Zhang , And at the age of 18 To 25 Students aged between
2.3 Alias query
() as () Put the expression result of the previous bracket use The name in parentheses indicates
select id, name, chinese + math + english as Total score from student;
2.4 Go to check again (distinct)
Remove the repeated data query in students' math scores
select distinct math from student;
2.5 Sort query (order by)
– ASC In ascending order ( From small to large )
– DESC For the descending order ( From big to small )
select name, qq_mail from student order by qq_mail;( Default ascending order )
select name, qq_mail from student order by qq_mail DESC;( Descending )
Example
Inquire about article In the article table , Article title title It's empty , Or meet the publication date create_date stay 2019 year 1 month 1 After the day
select * from article where title is null or create_date > ‘2019-1-1 00:00:00’;
3 Modify the operating
update Table name set
Modify all inventories greater than 30 Product records for , Increase the price 50 block
update goods set price = price + 50 where stock > 30;
modify “Java The core technology ” Book information of , Change the price to 61
update book set price = 61 where name = ‘java The core technology ’;
4. Delete operation
Delete the item table , The price is greater than 60, Or the inventory is less than 200 The record of
delete from goods where price > 60 or stock < 200;
边栏推荐
- xml转voc,voc转coco,coco转yolo,coco划分,coco检查,yolo检查,coco可视化
- Unity 3D人物的粒子消散
- Matrikon OPC 模拟器使用教程
- 散户炒股选哪个证券公司手续费低,手机上开户安全吗
- Mysql死锁、锁超时、慢sql总结
- 集群时钟同步配置
- 2022年下半年(软考高级)信息系统项目管理师认证招生简章
- m基于光纤光栅传感网接入GPON的光纤通信系统matlab性能仿真,包括解码,解封装,分接,码率恢复,解帧,拆包,译码
- FileUploadBase$SizeLimitExceededException
- RoleApp聚焦Web3,用“数据可持有”的钥匙开启Web3的大门
猜你喜欢
Implementation of fruit and vegetable mall management system based on SSM
Design of the multi live architecture in different places of the king glory mall
See Zhihu salt for free
Siemens S7 simulator tutorial
[go language] (I) environment building and understanding vscode tools
【Matlab】解决使用Mex 报错There was a problem creating the mex file for Real Time Execution ,Please ensure y
【论文阅读|浅读】RolX: Structural Role Extraction & Mining in Large Graphs
visual studio 2019 安装卸载问题
What is the key to implement MES management system
CPDA | first learn data analysis tools or data analysis thinking?
随机推荐
华为无线设备配置不同业务VLAN的AP间非快速漫游
C语言文件操作
最受IT公司欢迎的 30 款开源软件
MySQL deadlock, lock timeout, slow SQL summary
NPDP|没有技术背景能做好产品经理吗?
从wolai转移到Notion
基于STM32HAL库ADS1256调试笔记
FileUploadBase$SizeLimitExceededException
脱离炒作,数字藏品才能走得更远
潘多拉 IOT 开发板学习(RT-Thread)—— 实验16 WiFi 模块实验(学习笔记)
openharmony萌新贡献指南
【论文阅读|浅读】RolX: Structural Role Extraction & Mining in Large Graphs
1053 Path of Equal Weight
深入理解TCP協議
mysql建库建表(一)
CPDA | first learn data analysis tools or data analysis thinking?
软件测试技术之项目上线流程
2022年下半年系统集成项目管理工程师认证招生简章
d静态导入对象
页面请求拦截