当前位置:网站首页>Condition query
Condition query
2022-06-26 04:38:00 【Lili demon_】
Conditions of the query
grammar :SELECT Query list FROM Table name WHERE filter ;
- Filter by conditional expression
Simple conditional operators :<
>
=
(!=
<>
)>=
<=
- Filter by logical expression
Logical operators :AND
OR
NOT
- Fuzzy query
LIKE
BETWEEN AND
IN
IS NULL
Filter by conditional expression
#1. Query salary > 12000 Employee information
SELECT * FROM employees WHERE salary > 12000;
#2. Query department number is not equal to 90 Employee name and department number of
SELECT
CONCAT(last_name, " ", first_name) AS Employee name ,
department_id
FROM
employees
WHERE
department_id <> 90; # It's not equal to
Filter by logical expression
AND
#1. Check salary at 10000 To 20000 Between the employee's name , Salaries and bonuses
SELECT
CONCAT(last_name, " ", first_name) AS Employee name ,
salary,
commission_pct
FROM
employees
WHERE
salary >= 10000
AND salary <= 20000;
OR / NOT
#2. The inquiry department number is not in 90 To 110 Between , Or pay more than 15000 Employee information
SELECT
*
FROM
employees
WHERE
NOT (department_id >= 90 AND department_id <= 110)
OR salary > 15000;
Fuzzy query
LIKE
- Generally used with wildcards
- wildcard :
%
: Any number of characters ,_
: Any single character
#1. Query employee name contains characters “a” Employee information
SELECT * FROM employees WHERE last_name LIKE "%a%";
#2. The third character in the query employee name is "n", The fifth character is "l" The name and salary of the employee
SELECT last_name,salary
FROM employees where last_name LIKE "__n_l%";
#3. The second character in the employee name is “_” Employee name of
# ( Use escape characters \ or Any character Use ESCAPE)
SELECT last_name
FROM employees WHERE last_name LIKE "_$_%" ESCAPE "$";
BETWEEN AND
- Including left and right critical values
#1. Query the employee number in 100 To 120 Employee information between
SELECT * FROM employees WHERE employee_id BETWEEN 100 AND 120;
IN
#1. The job number of the employee is AD_VP,IT_PROG,AD_PRES The name and job number of one of the employees in
SELECT
last_name,
job_id
FROM
employees
WHERE
job_id IN (
"AD_VP",
"IT_PROG",
"AD_PRES");
IS NULL and IS NOT NULL
#1. Query the employee name and bonus rate without bonus
SELECT last_name,commission_pct
FROM employees WHERE commission_pct IS NULL;
SELECT last_name,commission_pct
FROM employees WHERE commission_pct IS NOT NULL;
<=>: Safety is equal to
- Can be judged NULL and Common value
SELECT last_name,commission_pct
FROM employees WHERE commission_pct <=> NULL;
边栏推荐
- 基础查询
- [Qunhui] command line acme SH automatically apply for domain name certificate
- #微信小程序# 在小程序里面退出退出小程序(navigator以及API--wx.exitMiniProgram)
- Solution to composer error could not find package
- 2022 talent strategic transformation under the development trend of digital economy
- Minecraft 1.16.5 生化8 模组 1.9版本 1.18版本同步
- 做软件测试学历重要还是能力重要
- Laravel uses phpword to generate word documents
- Install SVN in Pagoda and build SVN version Library
- 6、 Project practice --- identifying cats and dogs
猜你喜欢
NPM installation tutorial
Resolve PHP is not an internal or external command
[geek challenge 2019] rce me
Laravel framework Alipay payment fails to receive asynchronous callback request [original]
2021-02-07
A new paradigm for large model application: unified feature representation optimization (UFO)
Mysql8.0 configuring my SQL in INI file_ mode=NO_ AUTO_ CREATE_ User can start
OSS CDN alicloud configuration method
Install dbeaver and connect Clickhouse
Tp6 multi table Association (table a is associated with table B, table B is associated with table C, and table d)
随机推荐
Svn error command revert error previous operation has not finished; run ‘ cleanup‘ if
What is the best way to store chat messages in a database? [Close] - best way to store chat messages in a database? [closed]
08_ Spingboot integrated redis
Guide de la pompe de données Oracle
Ubuntu installs PostgreSQL and uses omnidb to view
1.19 learning summary
CTF crypto (I) some simple encoding and encryption
What are the advantages and risks of paper gold investment
PHP splits a string into arrays
TP5 distinct method paging problem
1.13 learning summary
1.14 learning summary
Laravel framework Alipay payment fails to receive asynchronous callback request [original]
CDN with OSS acceleration
Use shell script to analyze system CPU, memory and network throughput
Navicat connects the pit of shardingsphere sub table and sub library plug-ins
2020-12-18
CTF PHP audit bypasses filtering learning from topics
Laravel file stream download file
An unexpected attempt (Imperial CMS list template filters spaces and newlines in smalltext introduction)