As a basis, 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 to 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 () preferred.
If a string function has been given a binary string as a parameter, the resulting string is also a binary string. A number converted to a string is treated as a binary string. This only has an effect on the results of the comparison.
In general, if any of the expressions in a string comparison are case-sensitive, performing comparisons is case-sensitive.
Expr like Pat [ESCAPE ' Escape-char ']
pattern matching, using SQL simple regular expression comparisons. Returns 1 (TRUE) or 0 (FALSE). If either expr or PAT is null, the result is null.
The pattern does not need to be a literal string. For example, you can be specified as a string expression or a table column.
The following two wildcard characters can be used with like in the pattern:
mysql> SELECT 'David!' LIKE 'David_';
-> 1
mysql> SELECT 'David!' LIKE '%D%v%';
-> 1
To verify the text instance of the wildcard character, you can place the escape characters in front of the character. If the escape character is not specified, it is assumed to be '.
mysql> SELECT 'David!' LIKE 'David_';
-> 0
mysql> SELECT 'David_' LIKE 'David_';
-> 1