MySQL String Functions

MySQL String Functions
http://dev.mysql.com/doc/refman/5.6/en/string-functions.html

CHAR_LENGTH(str)
Returns number of characters in argument.
mysql> select char_length(“ß”);
+——————-+
| char_length(“ß”)  |
+——————-+
|                 1 |
+——————-+

INSTR(str,substr)
Returns the position of the first occurrence of substring substr in string str.
This is the same as the two-argument form of LOCATE(), except that the order of the arguments is rev ersed.

LEFT(str, len)
Returns the leftmost len characters from the string str, or NULL if any argument is NULL.

LENGTH()
Returns the length of the string str, measured in bytes. A multibyte character counts as multiple bytes. This means that for a string containing five 2-byte characters, LENGTH() returns 10, whereas CHAR_LENGTH() returns 5.
mysql> select length(“ß”);
+————–+
| length(“ß”)  |
+————–+
|            2 |
+————–+

expr LIKE pat [ESCAPE ‘escape_char’]
Pattern matching using SQL simple regular expression comparison. Returns 1 (TRUE) or 0 (FALSE). If either expr or pat is NULL, the result is NULL.
mysql> SELECT “a” = “a “, “a” LIKE “a “;
+————+—————+
| “a” = “a ” | “a” LIKE “a ” |
+————+—————+
|          1 |             0 |
+————+—————+
With LIKE you can use the following two wildcard characters in the pattern. …

LOCATE()
mysql> SELECT word_ID, word, category
-> FROM dictionary
-> WHERE LOCATE(“solution”, word) > 0;
http://www.w3resource.com/mysql/string-functions/mysql-locate-function.php

Collation of Expressions
http://dev.mysql.com/doc/refman/5.6/en/charset-collation-expressions.html

MySQL_all-words_LIKE

MySQL_LIKE-BINARY

MySQL_bit_length

MySQL_is_blind_to_angstroms

MySQL_angstrom

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s