Mysql函数和运算符(看一点写一点)
来源:互联网 发布:马士兵网上商城源码 编辑:程序博客网 时间:2024/06/05 16:29
CONCAT 连接函数
SELECT CONCAT(2,' test'); -> '2 test'
还能隐式把字符类型改成字符串
SELECT 38.8, CONCAT(38.8); -> 38.8, '38.8'
CAST字符类型转换
SELECT 38.8, CAST(38.8 AS CHAR); -> 38.8, '38.8'
运算符
AND
, &&
Logical AND=
Assign(分配) a value (as part of a SET
statement(声明), or as part of the SET
clause in an UPDATE
statement):=
Assign a valueBETWEEN ... AND ...
Check whether a value is within a range of valuesBINARY
Cast a string to a binary(二进制的) string&
Bitwise AND~
Bitwise(按位) inversion(倒置)|
Bitwise OR^
Bitwise XORCASE
Case operatorDIV
Integer(整数) division/
Division operator=
Equal operator<=>
NULL-safe equal to operator>
Greater than operator>=
Greater than or equal operatorIS
Test a value against a booleanIS NOT
Test a value against a booleanIS NOT NULL
NOT NULL value testIS NULL
NULL value test->
Return value from JSON column after evaluating(评价) path; equivalent(等价的) to JSON_EXTRACT().->>
Return value from JSON column after evaluating path and unquoting(结束) the result; equivalent to JSON_UNQUOTE(JSON_EXTRACT()).<<
Left shift<
Less than operator<=
Less than or equal operatorLIKE
Simple pattern matching-
Minus operator%
, MOD
Modulo(以…为模) operatorNOT
, !
Negates valueNOT BETWEEN ... AND ...
Check whether a value is not within a range of values!=
, <>
Not equal operatorNOT LIKE
Negation(否定) of simple pattern matchingNOT REGEXP
Negation of REGEXP||
, OR
Logical OR+
Addition operatorREGEXP
Pattern matching using regular expressions>>
Right shiftRLIKE
Synonym(同义词) for REGEXPSOUNDS LIKE
Compare sounds*
Multiplication(乘法) operator-
Change the sign of the argumentXOR
Logical XOR运算符优先级,同一行有相同的优先级
INTERVALBINARY, COLLATE!- (unary minus), ~ (unary bit inversion)^*, /, DIV, %, MOD-, +<<, >>&|= (comparison), <=>, >=, >, <=, <, <>, !=, IS, LIKE, REGEXP, INBETWEEN, CASE, WHEN, THEN, ELSENOTAND, &&XOROR, ||= (assignment), :=
比较运算符
Name Description
BETWEEN ... AND ...
Check whether a value is within a range of valuesCOALESCE()
Return the first non-NULL argument=
Equal operator<=>
NULL-safe equal to operator>
Greater than operator>=
Greater than or equal operatorGREATEST()
Return the largest argumentIN()
Check whether a value is within a set of valuesINTERVAL()
Return the index of the argument that is less than the first argumentIS
Test a value against a booleanIS NOT
Test a value against a booleanIS NOT NULL
NOT NULL value testIS NULL
NULL value testISNULL()
Test whether the argument is NULLLEAST()
Return the smallest argument<
Less than operator<=
Less than or equal operatorLIKE
Simple pattern matchingNOT BETWEEN ... AND ...
Check whether a value is not within a range of values!=
, <>
Not equal operatorNOT IN()
Check whether a value is not within a set of valuesNOT LIKE
Negation(否定) of simple pattern matchingSTRCMP()
Compare two stringsCOALESCE 返回第一个非空值,
使用情景:如果列为空值,不想返回null可以使用函数返回想要的值
SELECT COALESCE(NULL,1);
-> 1
GREATEST(value1,value2,...) 返回最大值mysql>INTERVAL(N,N1,N2,N3,...) 表示N值在列表中的位置SELECT GREATEST(2,0);
-> 2mysql>SELECT GREATEST(34.0,3.0,5.0,767.0);
-> 767.0mysql>SELECT GREATEST('B','A','C');
-> 'C'
mysql>如果N值为NULL,返回-1SELECT INTERVAL(23, 1, 15, 17, 30, 44, 200);
-> 3mysql>SELECT INTERVAL(10, 1, 10, 100, 1000);
-> 2mysql>SELECT INTERVAL(22, 23, 30, 44, 200);
-> 0
LEAST(value1,value2,...) 返回列表最小值
mysql>XOR OR的反义SELECT LEAST(2,0);
-> 0mysql>SELECT LEAST(34.0,3.0,5.0,767.0);
-> 3.0mysql>SELECT LEAST('B','A','C');
-> 'A'
字符串函数
ASCII()
Return numeric(数) value of left-most characterBIN()
Return a string containing binary(二进制的) representation(代表) of a numberBIT_LENGTH()
Return length of argument in bitsCHAR()
Return the character for each integer(整数) passedCHAR_LENGTH()
Return number of characters in argumentCHARACTER_LENGTH()
Synonym(同义词) for CHAR_LENGTH()CONCAT()
Return concatenated(连结) stringCONCAT_WS()
Return concatenate with separator(分离器)ELT()
Return string at index numberEXPORT_SET()
Return a string such that for every bit set in the value bits, you get an on string and for every unset bit, you get an off stringFIELD()
Return the index (position) of the first argument in the subsequent(后来的) argumentsFIND_IN_SET()
Return the index position of the first argument within the second argumentFORMAT()
Return a number formatted(格式化) to specified(规定的) number of decimal(小数) placesFROM_BASE64()
Decode(译码) to a base-64 string and return resultHEX()
Return a hexadecimal(十六进制的) representation(代表) of a decimal or string valueINSERT()
Insert a substring(子串) at the specified position up to the specified number of charactersINSTR()
Return the index of the first occurrence(发生) of substring(子串)LCASE()
Synonym(同义词) for LOWER()LEFT()
Return the leftmost(最左边的) number of characters as specified(指定)LENGTH()
Return the length of a string in bytesLIKE
Simple pattern matchingLOAD_FILE()
Load the named fileLOCATE()
Return the position of the first occurrence of substringLOWER()
Return the argument in lowercase(小写字母)LPAD()
Return the string argument, left-padded with the specified stringLTRIM()
Remove leading spacesMAKE_SET()
Return a set of comma-separated strings that have the corresponding bit in bits setMATCH
Perform full-text searchMID()
Return a substring(子串) starting from the specified(规定的) positionNOT LIKE
Negation(否定) of simple pattern matchingNOT REGEXP
Negation of REGEXPOCT()
Return a string containing octal(八进制的) representation(代表) of a numberOCTET_LENGTH()
Synonym(同义词) for LENGTH()ORD()
Return character code for leftmost(最左边的) character of the argumentPOSITION()
Synonym for LOCATE()QUOTE()
Escape the argument for use in an SQL statement(声明)REGEXP
Pattern matching using regular expressionsREPEAT()
Repeat a string the specified(规定的) number of timesREPLACE()
Replace occurrences(发生) of a specified stringREVERSE()
Reverse(相反) the characters in a stringRIGHT()
Return the specified rightmost number of charactersRLIKE
Synonym(同义词) for REGEXPRPAD()
Append(附加) string the specified number of timesRTRIM()
Remove trailing(后面的) spacesSOUNDEX()
Return a soundex(探测法) stringSOUNDS LIKE
Compare soundsSPACE()
Return a string of the specified(规定的) number of spacesSTRCMP()
Compare two stringsSUBSTR()
Return the substring(子串) as specifiedSUBSTRING()
Return the substring as specifiedSUBSTRING_INDEX()
Return a substring from a string before the specified number of occurrences(发生) of the delimiter(划界)TO_BASE64()
Return the argument converted(转变) to a base-64 stringTRIM()
Remove leading and trailing(追踪) spacesUCASE()
Synonym(同义词) for UPPER()UNHEX()
Return a string containing hex representation(代表) of a numberUPPER()
Convert to uppercase(以大写字母印刷)WEIGHT_STRING()
Return the weight string for a string 0 0
- Mysql函数和运算符(看一点写一点)
- (需要确认一点)C++ 析构函数和delete运算符
- 每天学一点Swift---- 运算符函数
- 写一点
- 良好的工作习惯和团队管理方法(想到一点写一点)
- 一些我的程序世界观(想一点写一点)
- 一点mysql注入时用到的函数
- 关于移位运算符和取反运算符的一点感悟
- MySQL 运算符和函数
- MySQL运算符和函数
- MySQL运算符和函数
- mysql 运算符和函数
- MySQL-运算符和函数
- MySQL运算符和函数
- MySQL 运算符和函数
- Mysql 运算符和函数
- mysql 运算符和函数
- 想写就写一点
- Ajax请求原理
- 安装devstack遇到的问题
- Select2插件的用法,通过ajax实现在下拉框中回显
- STM32实现USART+DMA接收未知长度的数据和发送
- vim taglist usage
- Mysql函数和运算符(看一点写一点)
- IOS开发中(null)与<null>的处理
- IE10兼容性视图,IE9等支持canvas标签
- Android界面UI的优化
- Spring Security Taglib
- 微信小程序之开发者工具介绍(三)
- 各种编码方案的由来
- Oracle函数执行提示“ORA-01422”,“ORA-06512”错误
- 洛谷1603 斯诺登的密码(第21题)