12 SQL String Functions You Should Know as a Data Scientist or Data Analyst | by SQL Fundamentals | Oct, 2024
SQL string functions are useful for manipulating and extracting information from string data in MySQL queries.
In this article, we will explore 12 essential SQL string functions such as CONCAT, REPLACE, LEFT, RIGHT, UPPER, LOWER, LENGHT, SUBSTRING, TRIM, INSTR, REVERSE and provide examples to help you understand their usage and unleash their potential in your data analysis tasks.
It concatenates two or more strings together.
Example:
SELECT CONCAT(column1, “ “, column2) AS concatenated_new_column
FROM table_name;
-- Select all the full names of employees as "employee_fullname".SELECT CONCAT(fname, " ", lname) AS employee_fullname
FROM employee;
-- Write a query to see the full names of authors (the same last name cannot appear more than once) and their addresses in a sentence. SELECT DISTINCT au_lname, au_fname, CONCAT(au_fname, " ", au_lname, "'s address is: ", address) AS authors_address_info
FROM authors;