The MySQL result string may be unfamiliar to many new users who are new to the MySQL database. The following describes the MySQL result string for your reference.
MySQL has many operators and functions that can return strings. What character set and collation are used for the returned string?
For simple functions, that is, receiving string input and returning a string result as the output function, the output character set and verification rules are the same as those of the original input. For example, UPPERX) returns a string with the same character and proofreading rules as X. Similar functions include INSTR (), LCASE (), LOWER (), LTRIM (), MID (), REPEAT (), REPLACE (), REVERSE (), RIGHT (), RPAD (), RTRIM (), SOUNDEX (), SUBSTRING (), TRIM (), UCASE (), and UPPER (). Note that the REPLACE () function is different from other functions. It always ignores the checking rules of input strings and makes case-insensitive comparisons .)
For operations that Merge multiple string inputs and return a single string output, use the standard SQL "aggregation rule ":
· If there is an explicit checking rule X, use X.
· If explicit checking rules X and Y exist, an error is generated.
· Otherwise, if all rules are checked as X, use X.
· In other cases, there are no rules for checking the results.
For example, use CASE... WHEN a THEN B WHEN B THEN c COLLATE X END. The result verification rule is X. CASE, UNION, CONCAT (), ELT (), GREATEST (), IF (), and LEAST () are the same.
For character data conversion, the character set and collation rules of the result string are defined by character_set_connection and collation_connection system variables. This applies to CAST (), CHAR (), CONV (), FORMAT (), HEX (), and SPACE () functions.
MySQL string truncation Function Method
MySQL string segmentation implementation
MySQL string addition function usage example
How to quickly enable MySQL slow log query
How to query duplicate records in MYSQL