Mysql string Functions


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

CONCAT_WS()


CONCAT_WS() stands for Concatenate With Separator and is a special form of CONCAT(). The first argument is the separator for the rest of the arguments. The separator is added between the strings to be concatenated. The separator can be a string, as can the rest of the arguments. If the separator is NULL, the result is NULL.
Syntax : CONCAT_WS(separator,str1,str2,...)
Example : SELECT CONCAT_WS(',','1st string','2nd string');
Output : 1st string,2nd string

ELT()


ELT() returns the Nth element of the list of strings: str1 if N = 1, str2 if N = 2, and so on. Returns NULL if N is less than 1 or greater than the number of arguments. ELT() is the complement of FIELD().
Syntax : ELT(N,str1,str2,str3,...)
Example : SELECT ELT(4,'this','is','the','elt');
Output : elt

EXPORT_SET()


Returns a string such that for every bit set in the value bits, you get an on string and for every bit not set in the value, you get an off string.
Syntax : EXPORT_SET(bits,on,off[,separator[,number_of_bits]])
Example : SELECT EXPORT_SET(5,'Y','N',',',3);
Output : Y,N,Y

FIELD()


Returns the index (position) of str in the str1, str2, str3, ... list. Returns 0 if str is not found.
Syntax : FIELD(str,str1,str2,str3,...)
Example : SELECT FIELD('ank', 'b', 'ank', 'of', 'monk');
Output : 2

FIND_IN_SET()


Returns a value in the range of 1 to N if the string str is in the string list strlist consisting of N substrings. A string list is a string composed of substrings separated by “,” characters.
Returns NULL if either argument is NULL. This function does not work properly if the first argument contains a comma (“,”) character.
Syntax : FIND_IN_SET(str,strlist)
Example : SELECT FIND_IN_SET('ank','b,ank,of,monk');
Output : 2

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