当前位置:网站首页>MySQL basic queries and operators
MySQL basic queries and operators
2022-07-27 20:48:00 【Xiao Tang (๑ & gt; & lt; ๑)】
Author's brief introduction : Hello everyone, I'm classmate Tang (๑><๑), You can call me Xiao Tang
Personal home page : Xiao Tang (๑><๑) The blog home page of
Series column : database
If bloggers are also beginners MySQL I hope you can practice more MySQL The question bank is on niuke.com, and a link has been attached to you , You can directly click to jump : Click the jump
Niuke network support ACM Mode , It is also recommended to brush algorithm questions !!!
The following article ------》
Catalog
6. The query result is an expression -- Arithmetic query
1. Raise the price of all commodities 10%:
2. Query the trade name as “ Haier washing machine ” Information about our products
(1) Query contains ’ pants ‘ All commodities of the word :
(2) Query to ’ The sea ‘ All goods that begin with the word :
(3) The second word is ’ Kou ‘ All of our products :
MySQL The basic query
Query concept :
Query is an important function in database management system , Data query should not simply return the information stored in the database
You should also filter the data as needed and determine what form the data is displayed
1. Check all products :
select * from Table name ;
2. Query a column :
select Name 1, Name 2 from Table name ;
3. Alias query :
select * from Table name as Alias ;
4. Column alias query :
select Name 1 as Alias , Name 2 as Alias ,from Table name ;
5. To duplicate value query :
When all columns are the same, the duplicate value will be removed ( In general, it will not appear --- Primary key )
select distinct Name from Table name ;
6. The query result is an expression -- Arithmetic query
select Name , Name +10 Alias from Table name ;
Alias used The result is +10 Show alias after The original table data will not be modified ;
Operator
Operator concept : After the table structure in the database is determined , The meaning of the data in the table has been determined , adopt mysql Operator can obtain another kind of data other than the table structure .
The following illustrates the application of operators with examples
1. Raise the price of all commodities 10%:
select pname ,price*1.1 as new_price from Table name ;
2. Query the trade name as “ Haier washing machine ” Information about our products
select *from Table name where pname=' Haier washing machine ';
(1)select *from Table name where price between 100 and 200;
(2) select *from Table name where price >=100 and price<=200;
3. The inquiry price is 200 or 800 All products of :
select *from Table name where price in(200,800);
in If only one value in the keyword bracket is satisfied
4.like----- Wildcard match
(1) Query contains ’ pants ‘ All commodities of the word :
select * from Table name where pname like ’% pants %‘;
(2) Query to ’ The sea ‘ All goods that begin with the word :
select * from Table name where pname like ’ The sea %‘;
(3) The second word is ’ Kou ‘ All of our products :
select * from Table name where pname like ’- Kou %‘;
5.NULL Use :
NULL Out-of-service = because NULL Not equal to any value ( Including itself )
Inquire about id Not for NULL The goods
select * from Table name where Name is not NULL;
6. Use of functions :
(1)least For the minimum :
select least(5,10,20);
select least(5,10,20)as smallnumber;
select least(5,null20);
If there is NULL Will not be compared Direct output NULL
(2)greatest For maximum
select greatest (10,30,20)as bignumber;
select greatest (10,null,20)as bignumber;
If there is NULL Will not be compared Direct output NULL
边栏推荐
- Leetcode:1498. Number of subsequences that meet the conditions [sort + bisection + power hash table]
- 金仓数据库 KingbaseES异构数据库移植指南 (3. KingbaseES移植能力支撑体系)
- 软件测试面试题:字符串 “axbyczdj“,如果得到结果“abcd
- MLX90640 红外热成像仪测温传感器模块开发笔记(七)
- Passive income: return to the original and safe two ways to earn
- Introduction to zepto
- Summary of simple topics
- EasyCVR平台添加RTSP设备时,出现均以TCP方式连接的现象是什么原因?
- MySQL learning record (III) multi table query, sub query, paging query, case statement, single line function
- Ie11 method of downloading doc PDF and other files
猜你喜欢
![[rctf2015]easysql-1 | SQL injection](/img/69/aa1fc60ecf9a0702d35d876e8c3dda.png)
[rctf2015]easysql-1 | SQL injection
![[dataset display annotation] VOC file structure + dataset annotation visualization + code implementation](/img/09/645ce4de40d18d8dd4532554826c9a.png)
[dataset display annotation] VOC file structure + dataset annotation visualization + code implementation

Jetpack Compose 性能优化指南——编译指标

I'm also drunk. Eureka delayed registration and this pit

JVS公众号登陆配置

Innovative cases | the growth strategy of digitalization of local life services and upgrading of Gaode brand

EasyCVR平台关闭录像为何还会有TS切片文件生成?

Redis queue, RDB learning

创新案例 | 本地生活服务数字化,高德品牌升级的增长战略

Nailing development document
随机推荐
2022.07.11
What app should individuals use for stock speculation to be safer and faster
用户和权限创建普通用户
Software test interview question: count the number in a queue, how many positive numbers and how many negative numbers, such as [1, 3, 5, 7, 0, -1, -9, -4, -5, 8]
[efficiency] abandon notepad++, this open source substitute is more awesome!
What is a multi-layer perceptron (what is a multi-layer perceptron)
How to monitor the running status and usage of NVIDIA Jetson
EasyCVR平台添加RTSP设备时,出现均以TCP方式连接的现象是什么原因?
Jetpack compose performance optimization guide - compilation metrics
金仓数据库 KingbaseES 异构数据库移植指南 (4. 应用迁移流程)
MySQL 日志错误日志
access control
2022-07-19 网工进阶(二十)BGP-路由优选、路由优选逐条分析
Check the internship salary of Internet companies: with it, you can also enter the factory
Linked list~~~
MySQL string function
IE11 下载doc pdf等文件的方法
Summary of simple topics
Following Huawei and MediaTek, the mobile phone chip manufacturer announced a donation of 7million yuan to Wuhan
Innovative cases | the growth strategy of digitalization of local life services and upgrading of Gaode brand