当前位置:网站首页>Operators in MySQL
Operators in MySQL
2022-07-28 00:53:00 【richest_ qi】
List of articles
Arithmetic operator
Arithmetic operator , Include +、-、*、/ perhaps DIV、% perhaps MOD( Remainder or modulus ).
- MySQL in ,
+Just add the numbers , If a non numeric type is encountered ,MySQL Will first try to convert it to a number , If the conversion fails , It is regarded as a numerical value 0 Handle . in other words , There is Implicit conversion . - MySQL in , String splicing uses functions
CONCAT(str1,str2,...)Realization . - Null values participate in the operation , The result of the operation is still null .
- MySQL in , Divisor is 0 when , The result is null , namely
NULL.
+ Just add the numbers
# MySQL in ,+ Just add the numbers , If a non numeric type is encountered ,MySQL Will first try to convert it to a number , If the conversion fails , It is regarded as a numerical value 0 Handle . in other words , There is Implicit conversion .
SELECT 100 + '2'
FROM DUAL; -- return 102
SELECT 100 + 'A'
FROM DUAL; -- return 100
SELECT 'A' + 'B'
FROM DUAL; -- return 0
String splicing function CONCAT()
# MySQL in , String splicing uses functions CONCAT() Realization
SELECT CONCAT('HEL','LO')
FROM DUAL; -- return HELLO
SELECT CONCAT('a','b','c')
FROM DUAL; -- return abc
Null values participate in the operation , The result is still null
SELECT 100 + NULL
FROM DUAL; -- return NULL
Divisor is 0 when , The result is empty.
SELECT 100/0
FROM DUAL; -- return NULL
Comparison operator
Comparison operator , Include =、<=>、<> perhaps !=、<、<=、>、>=,
Also include IS NULL、IS NOT NULL、ISNULL()、LEAST()、GREATEST()、BETWEEN AND、IN()、NOT IN()、LIKE、REGEXP、RLIKE.
=, The equal sign operator . If one side is numerical , The other side is non numeric , Then there is implicit conversion . namely , First try to convert non numeric values to numeric values , If the conversion fails , It is regarded as a numerical value 0 Handle .=, The equal sign operator . If both sides are strings , Compare the characters in the string ANSI code .=, The equal sign operator , If either side appearsNULL, The result of the comparison isNULL.<=>, Security equals operator . and=similar , The difference lies in ,<=>It can be done toNULLJudge .- The judgment field is
NULL:Field <=>NULL、Field IS NULL、ISNULL( Field ). - The judgment field is not
NULL:NOT Field <=>NULL、Field IS NOT NULL、NOT ISNULL( Field ). BETWEEN Conditional lower bound AND Conditional upper bound, Including boundaries .- Use
LIKEFuzzy query , among ,%, A character representing an indefinite number . Can represent 0 Characters , Can represent 1 Characters , It can also represent multiple characters ._, Represents any character .\, Escape character .ESCAPE character, Specify a character as an escape character .
REGEXP, Regular matching . Common wildcards are as follows ,^, Match the beginning .$, Match the end .., Matches any character .*, matching 0 One or more characters in front of it . such as ,x*, Match any number ofxcharacter ;[0-9]*, Match any number of numbers ;*, Match any number of any characters .[], Match any character in brackets . such as ,[abc], matchingaorborc;[a-zA-Z], Match any uppercase and lowercase letters ;[0-9], Match any number .
= and <=>
# If one side is numerical , The other side is non numeric , Then there is implicit conversion . namely , First try to convert non numeric values to numeric values , If the conversion fails , It is regarded as a numerical value 0 Handle .
SELECT 1='1',1='a',0='a','1'=1,'a'=1,'a'=0
FROM DUAL;
-- return 1 0 1 1 0 1
# If = On both sides are strings , Compare the characters in the string ANSI code
SELECT 'a'='a','ab'='ab','a'='b'
FROM DUAL;
-- return 1 1 0
# =, The equal sign operator , Either side appears NULL, The results for NULL
SELECT 1=NULL,NULL='a',NULL=NULL
FROM DUAL;
-- return NULL NULL NULL
# <=>, Security equals operator , and =( The equal sign operator ) similar
SELECT 1<=>'1',1<=>'a',0<=>'a','1'<=>1,'a'<=>1,'a'<=>0
FROM DUAL;
-- return 1 0 1 1 0 1
SELECT 'a'<=>'a','ab'<=>'ab','a'<=>'b'
FROM DUAL;
-- return 1 1 0
# <=>, Security equals operator , It can be done to NULL Judge
SELECT 1<=>NULL,NULL<=>'a',NULL<=>NULL
FROM DUAL;
-- return 0 0 1
SELECT *
FROM employees
WHERE commission_pct <=> NULL;
-- return 72 rows
IS NULL、IS NOT NULL and ISNULL()
# Query table employees in ,commission_pct by NULL The data of
SELECT *
FROM employees
WHERE commission_pct <=> NULL;
SELECT *
FROM employees
WHERE commission_pct IS NULL;
SELECT *
FROM employees
WHERE ISNULL(commission_pct);
# Query table employees in ,commission_pct Not for NULL The data of
SELECT *
FROM employees
WHERE NOT commission_pct <=> NULL;
SELECT *
FROM employees
WHERE commission_pct IS NOT NULL;
SELECT *
FROM employees
WHERE NOT ISNULL(commission_pct);
BETWEEN … AND …
# Check salary at [6000,8000] Employee information within the scope
SELECT *
FROM employees
WHERE salary BETWEEN 6000 AND 8000;
SELECT *
FROM employees
WHERE salary>=6000 AND salary<=8000;
SELECT *
FROM employees
WHERE salary>=6000 && salary<=8000;
# The salary inquiry is not available [6000,8000] Employee information within the scope
SELECT *
FROM employees
WHERE salary NOT BETWEEN 6000 AND 8000;
SELECT *
FROM employees
WHERE salary<6000 OR salary>8000;
SELECT *
FROM employees
WHERE salary<6000 || salary>8000;
IN() and NOT IN()
# Inquire about department_id by 10,20,30 Employee information
SELECT *
FROM employees
WHERE department_id IN (10,20,30);
SELECT *
FROM employees
WHERE department_id=10 OR department_id=20 OR department_id=30;
# Query salary is not 6000,7000,8000 Employee information
SELECT *
FROM employees
WHERE salary NOT IN(6000,7000,8000);
SELECT *
FROM employees
WHERE salary<>6000 && salary<>7000 && salary<>8000;
Fuzzy query :LIKE
# Inquire about last_name Contains characters 'a' Employee information
SELECT last_name
FROM employees
WHERE last_name LIKE '%a%';
# Inquire about last_name In characters 'a' Employee information at the beginning
SELECT last_name
FROM employees
WHERE last_name LIKE 'a%';
# Inquire about last_name Contains both characters 'a' Also contains characters 'e' Employee information
SELECT last_name
FROM employees
WHERE last_name LIKE '%a%' AND last_name LIKE '%e%';
SELECT last_name
FROM employees
WHERE last_name LIKE '%a%e%' OR last_name LIKE '%e%a%';
# Inquire about last_name The second character is 'a' Employee information
SELECT last_name
FROM employees
WHERE last_name LIKE '_a%';
Logical operators
Logical operators , Include NOT or !,AND or &&、OR or || 、XOR ( Logical XOR ).
AND and OR Can be used together , And AND The priority ratio OR High priority .
An operator
An operator , Include ~( According to the not )、&( Bitwise AND )、|( Press bit or )、^( Bitwise XOR )、>>( Right shift to position )、<<( Move left according to position ).
边栏推荐
- Network equipment hard core technology insider firewall and security gateway (11) secrets of zero contact office
- 592. Fraction addition and subtraction: introduction to expression calculation
- Arm releases the new a78/g78/n78 kernel! There is also a cortex-x Series CPU that supports customization
- ASML launched the first generation HMI multi beam detector: the speed is increased by 600%, which is suitable for 5nm and more advanced processes
- Jerry caused other messages to accumulate in the message pool [article]
- mysql数据库的基本操作(一)-——基于数据库
- How does matlab set the K-line diagram to classic red and green color matching?
- LED, nixie tube and key of single chip microcomputer
- Build Release Blogs
- Matlab | those matlab tips you have to know (4)
猜你喜欢

Data analysis: disassembly method (details)

Buildforge materials

红队大杀器 Behinder_v4.0(冰蝎4.0)
![Jerry, if you turn on Bluetooth again, one for two. When the mobile phone is connected to the prototype, it will appear and cannot be connected [chapter]](/img/6c/d4a45981a7fc87f6a82a91017f8ce8.png)
Jerry, if you turn on Bluetooth again, one for two. When the mobile phone is connected to the prototype, it will appear and cannot be connected [chapter]

mysql分表之后怎么平滑上线?

leetcode:1997. 访问完所有房间的第一天【跳跃dp】

点分治解析
![[meetup preview] openmldb + ONEFLOW: link feature engineering to model training to accelerate machine learning model development](/img/17/15c759aadafc335028d37380903ee7.jpg)
[meetup preview] openmldb + ONEFLOW: link feature engineering to model training to accelerate machine learning model development

蓝桥杯单片机第十一届国赛程序设计试题

Set data constructor
随机推荐
mysql分表之后怎么平滑上线?
[must read for new products] valuation analysis of Meishi technology, distributed audio-visual products and Solutions
一周年创作纪念日,冲吧少年郎
网络设备硬核技术内幕 防火墙与安全网关篇 (十二) 零接触办公的奥秘 下
Jerry's PWM setting and PWM IO selection [chapter]
scrollview、tableView嵌套解决方案
y79.第四章 Prometheus大厂监控体系及实战 -- prometheus的服务发现机制(十)
一文读懂CMake
Matlab | those matlab tips you have to know (2)
网络设备硬核技术内幕 防火墙与安全网关篇 (九) 虚拟化神器 (下)
数据可视化-《白蛇2:青蛇劫起》(3)
[CruiseControl]Build Result JSP
mysql数据库的基本操作(二)-——基于数据表
When Jerry made a phone call, recording to SD card /u disk was not enough [article]
Network device hard core technology insider firewall and security gateway (VII) virtualization artifact (Part 1)
The server is poisoned - the dish is the original sin
Y79. Chapter IV Prometheus' monitoring system and practice -- Prometheus' service discovery mechanism (10)
startUMl
激活最大化
MySQL limit使用及超大分页问题解决