In-depth study of MySQL result strings

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.