This article will introduce in detail the usage of mysql string functions CONCAT_WS and CONCAT (). If you need to know the usage and difference of these two functions, you can refer.
CONCAT (str1, str2 ,...)
MethodCONCAT (str1, str2
Two-Point usage of Mysql string function FIND_IN_SET ()
Summary: You can query fields separated by commas and forcibly sort the results.
First, let's look at a table:
Colid
Vyear
Area
Cast
, 31,32, 21,12
MySQL string truncation functions: left (), right (), substring (), substring_index (). There are also mid () and substr (). Here, mid () and substr () are equivalent to substring () functions. substring () functions are very powerful and flexible.
1
MySQL (9) -- string function (2), mysql string(8) Delete the TRIM (s1 FROM s) function of the specified string)
TRIM (s1 FROM s2) deletes all substrings s1 at both ends of string s. S1 is an optional direction. If no direction is specified, spaces
Implementation of Mysql custom random string, mysql string
A system was developed a few days ago and requires random strings. However, if mysql database functions are provided directly, the existing functions are used to create random strings.
1.
Oracle and MySQL String concatenation
I. MySQL
In Java, we usually use the plus sign (+) to concatenate strings. in MySQL, we can also use the plus sign (+). For example:
Add test data first
Create table test (Id INT,Name VARCHAR (10 ),Score
Mysql string function collection is more comprehensive bitsCN.com
For operations on the string position, the first position is marked as 1.
ASCII(str)
Returns a string.strASCII code value of the leftmost character.If
strIs a null
I just learned that MySQL's varchar type is case-insensitive by default, and the last space is ignored. C.5.5.1.CaseSensitivityinStringSearchesmysqlSELECTaA;
I just learned that MySQL's varchar type is case-insensitive by default, and the last
Mysql string processing functions
ASCII (char) returns the ASCII value of a character
BIT_LENGTH (str) returns the bit length of the string.
CONCAT (s1, s2 ..., Sn) replace s1, s2 ..., Connect the sn to a string
CONCAT_WS (sep, s1, s2 ..., Sn)
Mysql string escape function bitsCN.com
Insert a data table in mysql. if the data contains '/', it may cause a syntax error. you don't need to explain this. you know, you need to write an escape function. at the beginning, you want to directly use
If a string function provides a binary string as a parameter, the result string is also a binary string. The number converted to a string is treated as a binary string. This only affects the comparison.
If a string function provides a binary string
Suppose you have a table:
The code is as follows:
CREATE TABLE users (id int (6) Not NULL auto_increment,primary KEY (ID), user_name VARCHAR (m) not null,emails VARCHAR (x) T NULL);
Initialize the table and add some records.
The code is as
This article mainly introduced the MySQL string processing function detailed introduction, the summary, needs the friend to be possible to refer to under First, concise summary ASCII (char) return character ASCII code value bit_length (str)
Character type#官网: https://dev.mysql.com/doc/refman/5.7/en/char.html#注意: The arguments in char and varchar brackets refer to the length of the character #char type: fixed length, simple rough, wasted space, fast access speed range of character
Tag: cal. com specifies a numeric localhost character string local operationList of simple examples of functional usage
Function
Function
Usage
Example
Left ()
Returns a substring of the corresponding
String TypeChar and varchar When you define char and varchar , you need to set the length. Grammar:char (M); Maximum length is 255varchar (M); Maximum length is 65532 Different encoding lengths GBK The maximum is: 32767UTF8 max:21845M for length!
Official document:https://dev.mysql.com/doc/refman/5.7/en/comparison-operators.htmlOriginal:Comparison operations result in a value of 1 (TRUE), 0 (FALSE), or NULL. These operations work for both numbers and strings. Strings is automatically
String type a) char and varchar1. You need to specify the length of the character, the length of the char is the length of the character, and the length of the varchar is the length of the byte2. The length specified in char is the actual length
There are two types of string connection operations in the MySQL database.A. Syntax:1. CONCAT (string1,string2,...) Description: String1,string2 represents a string, and the CONCAT function will return NULL if one is null when the string is
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.