当前位置:网站首页>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';
边栏推荐
猜你喜欢

Data analysis, thinking, law breaking and professional knowledge -- analysis method (I)

Leetcode 6103 - minimum fraction to delete an edge from the tree

leetcode 6103 — 从树中删除边的最小分数

Cut point of undirected graph

FPGA - 7 Series FPGA internal structure clocking -04- multi area clock

JS inheritance and prototype chain

异步、郵件、定時三大任務

dotConnect for PostgreSQL数据提供程序

First hand evaluation of Reza electronics rz/g2l development board

机器学习术语
随机推荐
Machine learning terminology
Cut point of undirected graph
2022.2.14 resumption
d,ldc構建共享庫
Key wizard hit strange learning - automatic path finding back to hit strange points
Create your first Kivy program Hello word (tutorial includes source code)
正确甄别API、REST API、RESTful API和Web Service之间的异同
Trois tâches principales: asynchrone, courrier et timing
链表中的节点每k个一组翻转
[shutter] image component (configure local GIF image resources | load placeholder with local resources)
excel IF公式判断两列是否相同
Correctly distinguish the similarities and differences among API, rest API, restful API and web service
[day 29] given an integer, please find its factor number
matlab查找某一行或者某一列在矩阵中的位置
产业互联网的产业范畴足够大 消费互联网时代仅是一个局限在互联网行业的存在
合并K个已排序的链表
【FPGA教程案例5】基于vivado核的ROM设计与实现
Kivy教程大全之 创建您的第一个kivy程序 hello word(教程含源码)
Assets, vulnerabilities, threats and events of the four elements of safe operation
465. DFS backtracking of optimal bill balance