xxxxxxxxxx
# change gender from male to female, and from female to male
UPDATE salary SET sex =
CASE sex
WHEN 'm' THEN 'f'
ELSE 'm'
END;
# or
update Salary set sex = if(sex='m', 'f', 'm');
xxxxxxxxxx
##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');
xxxxxxxxxx
UPDATE tableName SET fieldName = REPLACE(fieldName, 'fromStringValue', 'toStringValue');
xxxxxxxxxx
##sql query with replace function
#syntax
UPDATE tableName
SET column_name = REPLACE(column_name, 'fromStringValue', 'toStringValue');
xxxxxxxxxx
UPDATE employees
SET
phone_number = REPLACE(phone_number, '.', '-');Code language: SQL (Structured Query Language) (sql)
xxxxxxxxxx
SELECT REPLACE(thestring_with-unwanted_chars, unwanted_chars, '')
xxxxxxxxxx
STUFF Function: This function is used to
overwrite existing character or inserts
a string into another string.
REPLACE function: This function is used
to replace the existing characters
of all the occurrences.
xxxxxxxxxx
REPLACE function: This function is used
to replace the existing characters
of all the occurrences.
xxxxxxxxxx
SELECT STUFF(KYCNo, CHARINDEX('050', KYCNo), LEN('050'), '600') AS Result
FROM Underwriting.LITBL_KYCInformation WHERE BranchCode='600'