sql remove characters from string code example

Example 1: sql query with replace function

##sql query with replace function
#syntax
UPDATE tableName
SET  column_name = REPLACE(column_name, 'fromStringValue', 'toStringValue');

#Example 
Update  tbl_employee
Set designation = REPLACE(designation, 'SEO', 'Developer');

Example 2: sql remove characters from string right

SELECT TRIM('   Exemple   ');						-- 'Exemple'
SELECT LTRIM('   Exemple   ');						-- 'Exemple   '
SELECT RTRIM('   Exemple   ');						-- '   Exemple'
SELECT TRIM(BOTH 'x' FROM 'xxxExemplexxx');			-- 'Exemple'
SELECT TRIM(LEADING 'x' FROM 'xxxExemplexxx');		-- 'Exemplexxx'
SELECT LTRIM('xxxExemplexxx', 'x');					-- 'Exemplexxx'
SELECT TRIM(TRAILING 'x' FROM 'xxxExemplexxx'); 	-- 'xxxExemple'
SELECT RTRIM('xxxExemple', 'x');					-- 'Exemplexxx'

Tags:

Sql Example