当前位置:网站首页>MySQL basic queries and operators
MySQL basic queries and operators
2022-07-28 17:51:00 【m0_ fifty-four million eight hundred and fifty-three thousand f】
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
边栏推荐
猜你喜欢
随机推荐
中南大学研究生复试机试题
mmdetection3D---(1)
封装、继承、多态
【C语言进阶】——剖析入微数据在内存中的存储 【下】(浮点数存储)
[p5.js actual combat] my self portrait
1.4-dos
【C语言必看】哟写BUG呢,我敢保证你踩过坑
ps快速制作全屏水印
数字滤波器(六)--设计FIR滤波器
有奖征文 | 2022 云原生编程挑战赛征稿活动开启!
Complete MySQL interview questions (updated in succession)
ROS零散知识点及错误解决
电工学数字电路自学笔记1.24
【p5.js实战】我的自画像
MySQL and idea connection
编译原理学习笔记1(编译原理概述与词法分析)
QT programming serial port assistant
【C语言笔记分享】自定义类型:结构体,枚举,联合(建议收藏)
pycharm连接到远程docker
点云处理--voxel filter

![[C language note sharing] - dynamic memory management malloc, free, calloc, realloc, flexible array](/img/3f/35c9ff3be5c0ef781ffcb537287a20.png)



![[advanced C language] - function pointer](/img/73/95380bb719f609e80de56985ed68fd.png)



