当前位置:网站首页>MySQL - database query - condition query
MySQL - database query - condition query
2022-07-03 01:20:00 【Sauerkraut】
Conditions of the query
We know from MySQL Used in table SELECT Statement to query data , To conditionally select data from a table , Can be WHERE Clause to SELECT In the sentence .
grammar
SELECT Field name FROM Table name WHERE Conditions ;
Operator table
BETWEEN Followed by the minimum value ,AND Followed by the maximum , It represents an interval , It contains the maximum value and the minimum value
IN(...) If the value we need is in parentheses, it means it is true
LIKE Fuzzy matching , Wildcards are required , One is _ To match a single character , The other is % Means to match any character
IS[NOT] NULL Judge whether a field is empty
Query requirement
1. Inquiry salary is equal to 3000 The employees'
SELECT * FROM emp WHERE sal=3000;
2. Query salary less than 1000 The employees'
SELECT * FROM emp WHERE sal<1000;
3. Query salary less than or equal to 1000 The employees'
SELECT * FROM emp WHERE sal<=1000;
4. Query employees without bonus
SELECT * FROM emp WHERE emp.comm IS NULL;
5. Query employees with bonuses
SELECT * FROM emp WHERE emp.comm IS NOT NULL;
6. Check salary at 1200 To 1800 Employees between ( contain 1200 and 1800)
SELECT * FROM emp WHERE sal>=1200 && sal<=1800;
SELECT * FROM emp WHERE sal>=1200 AND sal<=1800;
SELECT * FROM emp WHERE sal BETWEEN 1200 AND 1800;
7. The inquiry position is salesman , And the salary is less than 1500 The employees'
SELECT * FROM emp WHERE job='salesman' AND sal<1500;
8. Query salary as 800 or 3000 or 5000 The employees'
SELECT * FROM emp WHERE sal=800 OR sal=3000 OR sal=5000;
SELECT * FROM emp WHERE sal in(800,3000,5000);
9. Query employees whose names are four words wildcard Fuzzy query
SELECT * FROM emp WHERE ename LIKE '____';
10. The last person to query the name is S The employees' wildcard % Match any number of
SELECT * FROM emp WHERE ename LIKE '%S';
边栏推荐
- excel表格计算时间日期的差值,并转化为分钟数
- Swiftui component Encyclopedia: using scenekit and swiftui to build interactive 3D pie charts (tutorial with source code)
- dotConnect for PostgreSQL数据提供程序
- Excel if formula determines whether the two columns are the same
- (C language) data storage
- MySQL foundation 07-dcl
- Kivy tutorial - example of using Matplotlib in Kivy app
- Correctly distinguish the similarities and differences among API, rest API, restful API and web service
- Basic remote connection tool xshell
- R language ggplot2 visual faceting, visual facet_wrap bar plot, using strip Text function customize the size of the strip of each facet title in the facet graph (cutimi
猜你喜欢
MySQL
Trois tâches principales: asynchrone, courrier et timing
Excel removes the data after the decimal point and rounds the number
Draw love with go+ to express love to her beloved
Database SQL language 02 connection query
Leetcode 2097 - Legal rearrangement of pairs
JDBC courses
[flutter] icons component (fluttericon Download Icon | customize SVG icon to generate TTF font file | use the downloaded TTF icon file)
电话网络问题
Assets, vulnerabilities, threats and events of the four elements of safe operation
随机推荐
[FPGA tutorial case 5] ROM design and Implementation Based on vivado core
【第29天】给定一个整数,请你求出它的因子数
按键精灵打怪学习-回城买药加血
Esp32 simple speed message test of ros2 (limit frequency)
Mongodb common commands of mongodb series
The difference between relational database and non relational database
电话网络问题
Leetcode 6103 - minimum fraction to delete an edge from the tree
RISA rz/g2l processor introduction | frame diagram | power consumption | schematic diagram and hardware design guide
看疫情之下服装企业如何顺势而为
[system analyst's road] Chapter V double disk software engineering (development model development method)
tp6快速安装使用MongoDB实现增删改查
[self management] time, energy and habit management
465. DFS backtracking of optimal bill balance
Excel calculates the difference between time and date and converts it into minutes
Basic use of sringcloud & use of component Nacos
Arduino DY-SV17F自动语音播报
SwiftUI 组件大全之使用 SceneKit 和 SwiftUI 构建交互式 3D 饼图(教程含源码)
按键精灵打怪学习-自动寻路回打怪点
按键精灵打怪学习-多线程后台坐标识别