Mysql string Functions


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

MAKE_SET()


MySQL MAKE_SET() returns a set value (a string containing substrings separated by “,” characters) consisting of the strings that have the corresponding bit in the first argument.
Example : SELECT MAKE_SET(1,'a','b','c');
Output : a


Syntax : MAKE_SET(bits,str1,str2,...)
Example : SELECT MAKE_SET(1 | 4,'hello','nice',NULL,'world');
Output : hello


MID()


MySQL MID() extracts a substring from a string. The actual string, position to start extraction and length of the extracted string - all are specified as arguments.
Example : SELECT MID('sampletext',4,3);
Output : eso


Syntax : MID(str,pos,len)

OCT()


Returns a string representation of the octal value of N, where N is a longlong (BIGINT) number. Returns NULL if N is NULL.
Example : SELECT OCT(12);
Output : 14


Syntax : OCT(N)

ORD()


MySQL ORD() returns the code for the leftmost character if that character is a multi-byte (sequence of one or more bytes) one. If the leftmost character is not a multibyte character, ORD() returns the same value as the ASCII() function.
Example : SELECT ORD("sampletext");
Output : 119


Syntax : ORD(str)

POSITION()


MySQL POSITION() returns the position of a substring within a string..
Example : SELECT POSITION("ou" IN "sampletext");
Output : 6


Syntax : POSITION(substr IN str)

QUOTE()


Quotes a string to produce a result that can be used as a properly escaped data value in an SQL statement. The string is returned enclosed by single quotation marks and with each instance of backslash (“\”), single quote (“'”), ASCII NUL, and Control+Z preceded by a backslash. If the argument is NULL, the return value is the word “NULL” without enclosing single quotation marks.
Example : SELECT QUOTE(‘test‘’string');
Output : ‘test\’string'


Syntax : QUOTE(str)

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