Mysql string Functions


Download 369.29 Kb.
bet6/8
Sana14.12.2022
Hajmi369.29 Kb.
#1001659
1   2   3   4   5   6   7   8
Bog'liq
MySQL String Functions

REPEAT()


MySQL REPEAT() repeats a string for a specified number of times.
The function returns NULL either any either of the arguments are NULL.
Example : SELECT REPEAT('**-',5);
Output : **-**-**-**-**-


Syntax : REPEAT(str,count)

REPLACE()


MySQL REPLACE() replaces all the occurrences of a substring within a string.
Example : SELECT REPLACE(‘teststring','ur','r');
Output : teststring


Syntax : REPLACE(str,from_str,to_str)

REVERSE()


Returns a given string with the order of the characters reversed.
Example : SELECT REVERSE(‘test');
Output : tset


Syntax : REVERSE(str)

RIGHT()


MySQL RIGHT() extracts a specified number of characters from the right side of a given string.
Example : SELECT RIGHT('w3resource',8);
Output : resource


Syntax : RIGHT(str,len)

RPAD()


MySQL RPAD() function pads strings from right. The actual string which is to be padded as str, length of the string returned after padding as len and string which is used for padding as padstr is used as a parameters within the argument.
Example : SELECT RPAD('w3resource',15,'*');
Output : w3resource*****


Syntax : RPAD(str,len,padstr)

RTRIM()


MySQL RTRIM() removes the trailing spaces from a given string.
Example : SELECT RTRIM('w3resource ');
Output : w3resource (excludes the trailing spaces)


Syntax : RTRIM(str)

SOUNDEX()


MySQL SOUNDEX() function returns soundex string of a string.
Soundex is a phonetic algorithm for indexing names after English pronunciation of sound. You can use SUBSTRING() on the result to get a standard soundex string. All non-alphabetic characters in str are ignored. All international alphabetic characters outside the A-Z range are treated as vowels.
Example : SELECT SOUNDEX('w3resource');
Syntax : SOUNDEX(str)
Output : w6262



Download 369.29 Kb.

Do'stlaringiz bilan baham:
1   2   3   4   5   6   7   8




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling