当前位置:网站首页>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';
边栏推荐
- Asynchronous, email and scheduled tasks
- Kivy教程大全之 创建您的第一个kivy程序 hello word(教程含源码)
- Button wizard play strange learning - go back to the city to buy medicine and add blood
- Create your first Kivy program Hello word (tutorial includes source code)
- Merge K sorted linked lists
- Several cases of recursive processing organization
- 【第29天】给定一个整数,请你求出它的因子数
- 安全运营四要素之资产、脆弱性、威胁和事件
- 【FPGA教程案例6】基于vivado核的双口RAM设计与实现
- 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
猜你喜欢
随机推荐
The R language uses the ctree function in the party package to build conditional inference decision trees, uses the plot function to visualize the trained conditional inference decision tree, and the
[C language] branch and loop statements (Part 1)
Basic remote connection tool xshell
【系统分析师之路】第五章 复盘软件工程(开发模型开发方法)
leetcode 2097 — 合法重新排列数对
MySQL基础用法02
按鍵精靈打怪學習-多線程後臺坐標識別
MySQL --- 数据库查询 - 基本查询
d,ldc构建共享库
RISA rz/g2l processor introduction | frame diagram | power consumption | schematic diagram and hardware design guide
用Go+绘制爱心给心爱的她表白
tp6快速安装使用MongoDB实现增删改查
leetcode 6103 — 从树中删除边的最小分数
电话网络问题
MySQL foundation 05 DML language
Daily topic: movement of haystack
On Fibonacci sequence
excel IF公式判断两列是否相同
链表内指定区间反转
SwiftUI 组件大全之使用 SceneKit 和 SwiftUI 构建交互式 3D 饼图(教程含源码)









