Updating into string functions

Returns the numeric value of the leftmost character of the string str. SELECT ASCII('2'); --------------------------------------------------------- | ASCII('2') | --------------------------------------------------------- | 50 | --------------------------------------------------------- 1 row in set (0.00 sec) mysql SELECT ASCII('dx'); --------------------------------------------------------- | ASCII('dx') | --------------------------------------------------------- | 100 | --------------------------------------------------------- 1 row in set (0.00 sec) SELECT BIN(12); --------------------------------------------------------- | BIN(12) | --------------------------------------------------------- | 1100 | --------------------------------------------------------- 1 row in set (0.00 sec) SELECT BIT_LENGTH('text'); --------------------------------------------------------- | BIT_LENGTH('text') | --------------------------------------------------------- | 32 | --------------------------------------------------------- 1 row in set (0.00 sec) SELECT CHAR(77,121,83,81,'76'); --------------------------------------------------------- | CHAR(77,121,83,81,'76') | --------------------------------------------------------- | My SQL | --------------------------------------------------------- 1 row in set (0.00 sec) Returns the length of the string str, measured in characters.

ASCII() works for characters with numeric values from 0 to 255.

SELECT LENGTH('text'); --------------------------------------------------------- | LENGTH('text') | --------------------------------------------------------- | 4 | --------------------------------------------------------- 1 row in set (0.00 sec) Reads the file and returns the file contents as a string.

To use this function, the file must be located on the server host, you must specify the full pathname to the file, and you must have the FILE privilege.

As of My SQL 5.0.19, the character_set_filesystem system variable controls interpretation of filenames that are given as literal strings.

The first syntax returns the position of the first occurrence of substring substr in string str.

The first argument is the separator for the rest of the arguments.

The separator is added between the strings to be concatenated.

'); --------------------------------------------------------- | LPAD('hi',4,'?? ') | --------------------------------------------------------- | ?? hi | --------------------------------------------------------- 1 row in set (0.00 sec) SELECT LTRIM(' barbar'); --------------------------------------------------------- | LTRIM(' barbar') | --------------------------------------------------------- | barbar | --------------------------------------------------------- 1 row in set (0.00 sec) Returns a set value (a string containing substrings separated by .,.Returns 1 if expr matches pat; otherwise it returns 0. REGEXP is not case sensitive, except when used with binary strings.SELECT 'ABCDEF' REGEXP 'A%C%%'; --------------------------------------------------------- | 'ABCDEF' REGEXP 'A%C%%' | --------------------------------------------------------- | 0 | --------------------------------------------------------- 1 row in set (0.00 sec) SELECT 'ABCDE' REGEXP '.*'; --------------------------------------------------------- | 'ABCDE' REGEXP '.*' | --------------------------------------------------------- | 1 | --------------------------------------------------------- 1 row in set (0.00 sec) SELECT 'new*\n*line' REGEXP 'new\*.\*line'; --------------------------------------------------------- | 'new*\n*line' REGEXP 'new\*.\*line' | --------------------------------------------------------- | 1 | --------------------------------------------------------- 1 row in set (0.00 sec) SELECT REPEAT('My SQL', 3); --------------------------------------------------------- | REPEAT('My SQL', 3) | --------------------------------------------------------- | My SQLMy SQLMy SQL | --------------------------------------------------------- 1 row in set (0.00 sec) SELECT REPLACE(' 'w', 'Ww'); --------------------------------------------------------- | REPLACE(' 'w', 'Ww') | --------------------------------------------------------- | Ww Ww Ww.| --------------------------------------------------------- 1 row in set (0.00 sec) SELECT REVERSE('abcd'); --------------------------------------------------------- | REVERSE('abcd') | --------------------------------------------------------- | dcba | --------------------------------------------------------- 1 row in set (0.00 sec) SELECT RIGHT('foobarbar', 4); --------------------------------------------------------- | RIGHT('foobarbar', 4) | --------------------------------------------------------- | rbar | --------------------------------------------------------- 1 row in set (0.00 sec) SELECT RPAD('hi',5,'?If the arguments include any binary strings, the result is a binary string.A numeric argument is converted to its equivalent binary string form; if you want to avoid that, you can use an explicit type cast, as in this example: SELECT CONCAT('My', 'S', 'QL'); --------------------------------------------------------- | CONCAT('My', 'S', 'QL') | --------------------------------------------------------- | My SQL | --------------------------------------------------------- 1 row in set (0.00 sec) CONCAT_WS() stands for Concatenate With Separator and is a special form of CONCAT().

Search for updating into string functions:

updating into string functions-52

'); --------------------------------------------------------- | RPAD('hi',5,'? ') | --------------------------------------------------------- | hi??? | --------------------------------------------------------- 1 row in set (0.00 sec) SELECT RTRIM('barbar '); --------------------------------------------------------- | RTRIM('barbar ') | --------------------------------------------------------- | barbar | --------------------------------------------------------- 1 row in set (0.00 sec) Returns a soundex string from str.

Leave a Reply

Your email address will not be published. Required fields are marked *

One thought on “updating into string functions”