MySQL String Functions

MySQL String Functions

Returns number of characters in argument.
mysql> select char_length(“ß”);
| char_length(“ß”)  |
|                 1 |

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.

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. …

mysql> SELECT word_ID, word, category
-> FROM dictionary
-> WHERE LOCATE(“solution”, word) > 0;

Collation of Expressions







Leave a Reply

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

You are commenting using your 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