当前位置:网站首页>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';
边栏推荐
- 链表中的节点每k个一组翻转
- Detailed explanation of Q-learning examples of reinforcement learning
- The difference between relational database and non relational database
- 异步、邮件、定时三大任务
- Esp32 simple speed message test of ros2 (limit frequency)
- leetcode:701. 二叉搜索树中的插入操作【bst的插入】
- 正确甄别API、REST API、RESTful API和Web Service之间的异同
- Matlab finds the position of a row or column in the matrix
- excel去除小数点后面的数据,将数字取整
- Specified interval inversion in the linked list
猜你喜欢
![[fh-gfsk] fh-gfsk signal analysis and blind demodulation research](/img/8a/8ca80f51a03341c982d52980c54b01.png)
[fh-gfsk] fh-gfsk signal analysis and blind demodulation research

Find a benchmark comrade in arms | a million level real-time data platform, which can be used for free for life

正确甄别API、REST API、RESTful API和Web Service之间的异同

excel去除小数点后面的数据,将数字取整

How wide does the dual inline for bread board need?

Basic remote connection tool xshell

matlab将数字矩阵保存为地理空间数据出错,显示下标索引必须为正整数类型或逻辑类型,解决

What is needed to develop a domestic arm intelligent edge computing gateway

【FH-GFSK】FH-GFSK信号分析与盲解调研究

Merge K sorted linked lists
随机推荐
Canvas drawing -- bingdd
MySQL foundation 07-dcl
1696C. Fishingprince plays with array [thinking questions + intermediate state + optimized storage]
Matlab saves the digital matrix as geospatial data, and the display subscript index must be of positive integer type or logical type. Solve the problem
12_ Implementation of rolling automatic video playback effect of wechat video number of wechat applet
excel去除小数点后面的数据,将数字取整
【系统分析师之路】第五章 复盘软件工程(开发模型开发方法)
【C语言】指针与数组笔试题详解
leetcode:871. Minimum refueling times [Pat has done before + maximum stacking + greed]
Every k nodes in the linked list are flipped
MySQL basic usage 02
Excel calculates the difference between time and date and converts it into minutes
JDBC courses
信息熵的基础
[Androd] Gradle 使用技巧之模块依赖替换
1038 Recover the Smallest Number
Basic remote connection tool xshell
1696C. Fishingprince Plays With Array【思维题 + 中间状态 + 优化存储】
不登陆或者登录解决oracle数据库账号被锁定。
2022.2.14 resumption