MySQL String Functions are built-in functions used to manipulate and process text data. They help in formatting, searching, extracting, and modifying string values stored in database tables.
String functions are applied inside SQL queries, mostly within the SELECT statement.
FUNCTION_NAME(string, arguments)
Returns the length of a string in characters.
// Get length of a string
SELECT LENGTH('MySQL Database');
Combines multiple strings into one.
// Combine first name and last name
SELECT CONCAT('MySQL',' ','Server');
Convert string to uppercase or lowercase.
// Convert string to uppercase
SELECT UPPER('mysql');
// Convert string to lowercase
SELECT LOWER('MYSQL');
Extracts a portion of a string.
// Extract 5 characters starting from position 1
SELECT SUBSTRING('Database',1,5);
Removes leading and trailing spaces.
// Remove extra spaces from string
SELECT TRIM(' MySQL ');
These functions return transformed string values directly in the query result. They are often used for formatting output, cleaning user input, or preparing reports.
Test the functions live below. Enter a string and click a button to see the MySQL result.