MySQL UCASE Function

Example

Convert the text to upper-case:

SELECT UCASE("SQL Tutorial is FUN!");

Definition and Usage

The UCASE() function converts a string to upper-case.

Note: This function is equal to the UPPER() function. Continue reading MySQL UCASE Function

MySQL TRIM Function

Example

Remove leading and trailing spaces from a string:

SELECT TRIM('    SQL Tutorial    ') AS TrimmedString;

Definition and Usage

The TRIM() function removes leading and trailing spaces from a string. Continue reading MySQL TRIM Function

MySQL SUBSTRING_INDEX Function

Example

Return a substring of a string before a specified number of delimiter occurs:

SELECT SUBSTRING_INDEX("www.iampsp.com", ".", 1);

Definition and Usage

The SUBSTRING_INDEX() function returns a substring of a string before a specified number of delimiter occurs. Continue reading MySQL SUBSTRING_INDEX Function

MySQL SUBSTRING Function

Example

Extract a substring from a string (start at position 1, extract 3 characters):

SELECT SUBSTRING("SQL Tutorial", 1, 3) AS ExtractString;

Definition and Usage

The SUBSTRING() function extracts a substring from a string (starting at any position). Continue reading MySQL SUBSTRING Function

MySQL SUBSTR Function

Example

Extract a substring from a string (start at position 5, extract 3 characters):

SELECT SUBSTR("SQL Tutorial", 5, 3) AS ExtractString;

Definition and Usage

The SUBSTR() function extracts a substring from a string (starting at any position). Continue reading MySQL SUBSTR Function

MySQL STRCMP Function

Example

Compare two strings:

SELECT STRCMP("SQL Tutorial", "SQL Tutorial");

Definition and Usage

The STRCMP() function compares two strings. Continue reading MySQL STRCMP Function

MySQL RTRIM Function

Example

Remove trailing spaces from a string:

SELECT RTRIM("SQL Tutorial     ") AS RightTrimmedString;

Definition and Usage

The RTRIM() function removes trailing spaces from a string. Continue reading MySQL RTRIM Function

MySQL RPAD Function

Example

Right-pad the string with “ABC”, to a total length of 20:

SELECT RPAD("SQL Tutorial", 20, "ABC");

Definition and Usage

The RPAD() function right-pads a string with another string, to a certain length.

Note: Also look at the LPAD() function. Continue reading MySQL RPAD Function

MySQL RIGHT Function

Example

Extract 4 characters from a string (starting from right):

SELECT RIGHT("SQL Tutorial is cool", 4) AS ExtractString;

Definition and Usage

The RIGHT() function extracts a number of characters from a string (starting from right).

Tip: Also look at the LEFT() function. Continue reading MySQL RIGHT Function