当前位置:网站首页>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';
边栏推荐
- [Arduino experiment 17 L298N motor drive module]
- MongoDB系列之MongoDB常用命令
- MySQL foundation 07-dcl
- [FPGA tutorial case 6] design and implementation of dual port RAM based on vivado core
- d,ldc構建共享庫
- 【无标题】
- 18_ The wechat video number of wechat applet scrolls and automatically plays the video effect to achieve 2.0
- 2022.2.14 resumption
- 1038 Recover the Smallest Number
- Machine learning terminology
猜你喜欢
随机推荐
链表内指定区间反转
机器学习术语
Linear programming of mathematical modeling (including Matlab code)
dotConnect for PostgreSQL数据提供程序
[Androd] Gradle 使用技巧之模块依赖替换
Several cases of recursive processing organization
matlab将数字矩阵保存为地理空间数据出错,显示下标索引必须为正整数类型或逻辑类型,解决
Trois tâches principales: asynchrone, courrier et timing
看疫情之下服装企业如何顺势而为
R language ggplot2 visualization: use ggplot2 to display dataframe data that are all classified variables in the form of thermal diagram, and customize the legend color legend of factor
The latest analysis of tool fitter (technician) in 2022 and the test questions and analysis of tool fitter (technician)
Basic concept and implementation of overcoming hash
Now that the teenager has returned, the world's fireworks are the most soothing and ordinary people return to work~
1038 Recover the Smallest Number
MySQL foundation 06 DDL
excel表格计算时间日期的差值,并转化为分钟数
[C language] branch and loop statements (Part 1)
tp6快速安装使用MongoDB实现增删改查
[untitled]
FPGA - 7系列 FPGA内部结构之Clocking -04- 多区域时钟






![[untitled]](/img/fd/f6b90536f10325a6fdeb68dc49c72d.png)


