MySQL automatically converts numbers to strings, and vice versa. MysqlSELECT1 + 1;
MySQL automatically converts numbers to strings, and vice versa. Mysql SELECT 1 + '1';-2 mysql select concat (2, 'test');-'2 test' If You Want To explicitly convert numbers into strings, you can use CAST () or CONCAT () function: mysql SELECT 38.8, CAST (38.8 as char);-38.8, '38. 8' mysql
MySQL automatically converts numbers to strings, and vice versa.
mysql> SELECT 1+'1'; -> 2 mysql> SELECT CONCAT(2,' test'); -> '2 test' |
To explicitly convert a number into a string, use the CAST () or CONCAT () function:
mysql> SELECT 38.8, CAST(38.8 AS CHAR); -> 38.8, '38.8' mysql> SELECT 38.8, CONCAT(38.8); -> 38.8, '38.8' |
CAST () is preferred.
If you have given a binary string as a parameter to a string function, the resulting string is also a binary string. A number converted to a string is treated as a binary string. This will only affect the comparison results.
Generally, if any expression in the string comparison is case sensitive, the comparison is case sensitive.
◆ Expr LIKE pat [ESCAPE 'escape-char ']
Use a simple SQL Regular Expression for comparison. Returns 1 (TRUE) or 0 (FALSE ). If either expr or pat is NULL, the result is NULL.
The mode does not need to be a text string. For example, it can be specified as a string expression or table column.
In the mode, you can use the following two wildcards with LIKE:
498) this. width = 498; 'onmousewheel = 'javascript: return big (this) 'height = 81 alt = "" src = "/files/uploadimg/20090224/1615510 .jpg" width = 331 border = 0>
mysql> SELECT 'David!' LIKE 'David_'; -> 1 mysql> SELECT 'David!' LIKE '%D%v%'; -> 1
|
To check the text of a wildcard, place the escape character before the character. If the ESCAPE character is not specified, it is assumed to be '\'.
498) this. width = 498; 'onmousewheel = 'javascript: return big (this) 'height = 110 alt = "" src = "/files/uploadimg/20090224/1615511 .jpg" width = 217 border = 0>
mysql> SELECT 'David!' LIKE 'David\_'; -> 0 mysql> SELECT 'David_' LIKE 'David\_'; -> 1
|
To specify a different ESCAPE character, use the ESCAPE statement:
mysql> SELECT 'David_' LIKE 'David|_' ESCAPE '|'; -> 1
|
The escape sequence can be null or a character length. From MySQL 5.1.2, if NO_BACKSLASH_ESCAPES SQL mode is activated, the sequence cannot be empty.
The following two statements show that strings are case insensitive unless one of the operands is a binary string:
mysql> SELECT 'abc' LIKE 'ABC'; -> 1 mysql> SELECT 'abc' LIKE BINARY 'ABC'; -> 0
|