当前位置:网站首页>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
边栏推荐
- Redis queue, RDB learning
- Management of user organization structure
- Summary of simple topics
- Linked list~~~
- 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]
- Analysis on the optimization of login request in IM development of instant messaging mobile terminal
- openresty lua-resty-dns 域名解析
- greedy
- MySQL 日志查询日志
- 未定义变量 “Lattice“ 或类 “Lattice.latticeEasy“(Matlab)
猜你喜欢

When adding RTSP devices to easycvr platform, what is the reason for the phenomenon that they are all connected by TCP?

How to solve the problem of missing alarm information and synchronization when Haikang equipment is connected to easycvr?

Arduino开发(二)_基于Arduino UNO开发板的RGB灯光控制方法

JVs official account login configuration

【分层强化学习】HAC论文及代码

金仓数据库 Oracle 至 KingbaseES 迁移最佳实践 (4. Oracle数据库移植实战)

2022.07.11

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

JVM overview and memory management (to be continued)

Jetpack Compose 性能优化指南——编译指标
随机推荐
Knowledge dry goods: basic storage service novice Experience Camp
软件测试面试题:统计在一个队列中的数字,有多少个正数,多少个负数,如[1, 3, 5, 7, 0, -1, -9, -4, -5, 8]
Introduction to zepto
【阿里安全 × ICDM 2022】20万奖金池!大规模电商图上的风险商品检测赛火热报名中!...
金仓数据库 Oracle 至 KingbaseES 迁移最佳实践 (4. Oracle数据库移植实战)
【效率】弃用 Notepad++,这款开源替代品更牛逼!
【毕设教程】YOLOv7 目标检测网络解读
What app should individuals use for stock speculation to be safer and faster
Software test interview question: how to output "0001" when a number is known to be 1
Common methods of object learning [clone and equals]
Scrollintoview realizes simple anchor location (example: select city list)
学术分享 | 清华大学 康重庆:电力系统碳计量技术与应用(Matlab代码实现)
Leetcode:1498. Number of subsequences that meet the conditions [sort + bisection + power hash table]
Data warehouse construction - DWD floor
Oracle simple advanced query
用户和权限创建普通用户
Oracle Xe installation and user operation
vi工作模式(3种)以及模式切换(转换)
Jetpack compose performance optimization guide - compilation metrics
MySQL log query log