SQL String Functions

SQL String functions are a set of built-in functions that are used to manipulate strings or character data in SQL. These functions can be used to extract, transform and manipulate data stored in character data type columns.

Here are some of the most commonly used SQL string functions:

CONCAT This function is used to concatenate two or more strings into a single string.

SELECT CONCAT('Hello', 'World');
Output: HelloWorld

SUBSTRING This function is used to extract a substring from a given string.

SELECT SUBSTRING('Hello World', 1, 5);
Output: Hello

LEN This function is used to get the length of a string.

SELECT LENGTH('Hello World');
Output: 11

REPLACE This function is used to replace a part of a string with another string.

SELECT REPLACE('Hello World', 'Hello', 'Hi');
Output: Hi World

UPPER This function is used to convert a string to uppercase.

SELECT UPPER('Hello World');
Output: HELLO WORLD

LOWER This function is used to convert a string to lowercase.

SELECT LOWER('Hello World');
Output: hello world

TRIM This function is used to remove extra spaces from the beginning and end of a string.

SELECT TRIM(' Hello World ');
Output: Hello World

These are just a few of the many SQL string functions that can be used to manipulate strings in a database. Knowing these functions can help you to efficiently query and manipulate data in your database.