当前位置:网站首页>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';
边栏推荐
- 拥抱平台化交付的安全理念
- [FPGA tutorial case 5] ROM design and Implementation Based on vivado core
- Compare version number
- leetcode:871. 最低加油次数【以前pat做过 + 最大堆 +贪心】
- 有向图的强连通分量
- kivy教程之在 Kivy App 中使用 matplotlib 的示例
- [day 29] given an integer, please find its factor number
- Strongly connected components of digraph
- 按键精灵打怪学习-回城买药加血
- Specified interval inversion in the linked list
猜你喜欢
12_ Implementation of rolling automatic video playback effect of wechat video number of wechat applet
拥抱平台化交付的安全理念
Data analysis, thinking, law breaking and professional knowledge -- analysis method (I)
强化学习 Q-learning 实例详解
[shutter] image component (cached_network_image network image caching plug-in)
安全运营四要素之资产、脆弱性、威胁和事件
【FPGA教程案例6】基于vivado核的双口RAM设计与实现
MySQL --- 数据库查询 - 条件查询
【我的OpenGL学习进阶之旅】关于欧拉角、旋转顺序、旋转矩阵、四元数等知识的整理
无向图的割点
随机推荐
Delete duplicate elements in the ordered linked list -ii
Excel calculates the difference between time and date and converts it into minutes
Button wizard play strange learning - go back to the city to buy medicine and add blood
2022.2.14 resumption
按键精灵打怪学习-自动寻路回打怪点
Matlab finds the position of a row or column in the matrix
产业互联网的产业范畴足够大 消费互联网时代仅是一个局限在互联网行业的存在
【C语言】分支和循环语句(上)
【C语言】指针与数组笔试题详解
[day 29] given an integer, please find its factor number
R language uses coin package to apply permutation tests to independence problems (permutation tests, whether response variables are independent of groups, are two numerical variables independent, and
Matlab Doppler effect produces vibration signal and processing
Database SQL language 02 connection query
dotConnect for PostgreSQL数据提供程序
Detailed explanation of Q-learning examples of reinforcement learning
[自我管理]时间、精力与习惯管理
12_ Implementation of rolling automatic video playback effect of wechat video number of wechat applet
信息熵的基础
Arduino DY-SV17F自动语音播报
MySQL foundation 06 DDL