SlideShare a Scribd company logo
1 of 45
MySQL String Functions
©w3resource
MySQL String Functions
©w3resource
ASCII()
This function returns the numeric value of the leftmost character of the string str.
Returns 0 if str is the empty string. Returns NULL if str is NULL
Syntax : ASCII(str)
Example : SELECT ASCII('2');
Output : 50
Example : SELECT ASCII(2);
Output : 50
Example : SELECT ASCII(‘An’);
Output : 65
©w3resource
BIN()
Returns a string representation of the binary value of N, where N is a longlong
(BIGINT) number. Returns NULL if N is NULL.
Syntax : BIN(N)
Example : SELECT BIN(12);
Output : 1100
©w3resource
BIT_LENGTH()
Returns the length of the string str in bits.
Syntax : BIT_LENGTH(str)
Example : SELECT BIT_LENGTH('text');
Output : 32
©w3resource
CHAR()
CHAR() interprets each argument N as an integer and returns a string consisting
of the characters given by the code values of those integers. NULL values are
skipped.
Syntax : CHAR(N,... [USING charset_name])
Example : SELECT CHAR(77,121,83,81,'76');
Output : MySQL
Example : SELECT CHAR(77,77.3,'77.3');
Output : MMM
©w3resource
CHAR_LENGTH()
Returns the length of the string str, measured in characters. A multi-byte character
counts as a single character. This means that for a string containing five 2-byte
characters, LENGTH() returns 10, whereas CHAR_LENGTH() returns 5.
Syntax : CHAR_LENGTH(str)
Example : SELECT CHAR_LENGTH('test string');
Output : 11
©w3resource
CONCAT()
Returns the string that results from concatenating one or more arguments. If all
arguments are nonbinary strings, the result is a nonbinary string. If the arguments
include any binary strings, the result is a binary string. A numeric argument is
converted to its equivalent nonbinary string form.
Syntax : CONCAT(str1,str2,...)
Example : SELECT CONCAT('w3resource','.','com');
Output : w3resource.com
©w3resource
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
©w3resource
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
©w3resource
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
©w3resource
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
©w3resource
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
©w3resource
FORMAT()
Formats the number X to a format like '#,###,###.##', rounded to D decimal
places, and returns the result as a string. If D is 0, the result has no decimal point
or fractional part.
Syntax : FORMAT(X,D)
Example : SELECT FORMAT(12332.123456, 4);
Output : 12,332.1235
Example : SELECT FORMAT(12332.1,4);
Output : 12,332.1000
Example : SELECT FORMAT(12332.2,0);
Output : 12,332
©w3resource
HEX()
MySQL HEX() returns a string representation of hexadecimal value of a decimal
or string value specified as argument.
If the argument is a string, each character in the argument is converted to two
hexadecimal digits.
If the argument is decimal, the function returns a hexadecimal string
representation of the argument , and treated as a longlong(BIGINT) number.
Syntax : HEX(str), HEX(N)
Example : SELECT HEX(157);
Output : 9D
©w3resource
INSERT()
Returns the string str, with the substring beginning at position pos and len
characters long replaced by the string newstr. Returns the original string if pos is
not within the length of the string. Replaces the rest of the string from position pos
if len is not within the length of the rest of the string.
Syntax : INSERT(str,pos,len,newstr)
Example : SELECT INSERT('Originalstring', 4, 5, ' insert ');
Output : Ori insert string
Example : SELECT INSERT('Originalstring', -3, 5, ' insert ');
Output : Originalstring
©w3resource
INSTR()
MySQL INSTR() takes a string and a substring of it as arguments, and returns an
integer which indicates the position of the first occurrence of the substring within
the string
Syntax : INSTR(str,substr)
Example : SELECT INSTR('myteststring','st');
Output : 5
©w3resource
LCASE()
MySQL LCASE() converts the characters of a string to lower case characters.
Syntax : LCASE(str)
Example : SELECT LCASE('MYTESTSTRING');
Output : myteststring
©w3resource
LEFT()
MySQL LEFT() returns a specified number of characters from the left of a given
string. Both the number and the string are supplied in the arguments as str and
len of the function.
Syntax : LEFT(str,len)
Example : SELECT LEFT('w3resource', 3);
Output : w3r
©w3resource
LENGTH()
MySQL LENGTH() returns the length of a given string.
Syntax : LENGTH(str)
Example : SELECT LENGTH('text');
Output : 4
©w3resource
LOCATE()
MySQL LOCATE() returns the position of the first occurrence of a string within a
string. Both of these strings are passed as arguments. An optional argument may
be used to specify from which position of the string (i.e. string to be searched)
searching will start. If this position is not mentioned, searching starts from the
beginning.
Syntax : LOCATE(substr,str,pos)
Example : SELECT LOCATE('st','myteststring');
Output : 5
©w3resource
LOWER()
MySQL LOWER() converts all the characters in a string to lowercase characters.
Syntax : LOWER(str)
Example : SELECT LOWER('MYTESTSTRING');
Output : myteststring
©w3resource
LPAD()
MySQL LPAD() left pads a string with another string. The actual string, a number
indicating the length of the padding in characters (optional) and the string to be
used for left padding - all are passed as arguments.
Syntax : LPAD(str,len,padstr)
Example : SELECT LPAD('Hello',10,'**');
Output : *****Hello
Example : SELECT LPAD('hi',1,'**');
Output : h
©w3resource
LTRIM(str)
MySQL LTRIM() removes the leading space characters of a string passed as
argument.
Syntax : LTRIM(str)
Example : SELECT LTRIM(' Hello')
Output : Hello ( leading spaces have been exclude)
©w3resource
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
©w3resource
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('w3resource',4,3);
Output : eso
Syntax : MID(str,pos,len)
©w3resource
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)
©w3resource
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("w3resource");
Output : 119
Syntax : ORD(str)
©w3resource
POSITION()
MySQL POSITION() returns the position of a substring within a string..
Example : SELECT POSITION("ou" IN "w3resource");
Output : 6
Syntax : POSITION(substr IN str)
©w3resource
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('w3re''source');
Output : 'w3re'source'
Syntax : QUOTE(str)
©w3resource
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)
©w3resource
REPLACE()
MySQL REPLACE() replaces all the occurrences of a substring within a string.
Example : SELECT REPLACE('w3resource','ur','r');
Output : w3resorce
Syntax : REPLACE(str,from_str,to_str)
©w3resource
REVERSE()
Returns a given string with the order of the characters reversed.
Example : SELECT REVERSE('w3resource');
Output : ecruoser3w
Syntax : REVERSE(str)
©w3resource
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)
©w3resource
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)
©w3resource
RTRIM()
MySQL RTRIM() removes the trailing spaces from a given string.
Example : SELECT RTRIM('w3resource ');
Output : w3resource (excludes the trailing spaces)
Syntax : RTRIM(str)
©w3resource
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
©w3resource
SPACE()
MySQL SPACE() returns the string containing a number of spaces as specified in
the argument.
Example : SELECT 'start', SPACE(10), 'end';
Syntax : SPACE(N)
Output : start end SPACE(10)
©w3resource
SUBSTR()
MySQL SUBSTR() returns the specified number of characters from a particular
position of a given string. SUBSTR() is a synonym for SUBSTRING().
Example : SELECT SUBSTR('w3resource',4,3);
Syntax : SUBSTR(str,pos,len)
Output : eso
©w3resource
SUBSTRING()
MySQL SUBSTRING() returns a specified number of characters from a particular
position of a given string.
Example : SELECT SUBSTRING('w3resource',4,3);
Syntax : SUBSTRING(str,pos,len)
Output : eso
Example : SELECT SUBSTRING('w3resource.com',5);
Output : source.com
Example : SELECT SUBSTRING('w3resource.com',-5);
Output : e.com
©w3resource
SUBSTRING_INDEX()
MySQL SUBSTRING_INDEX() returns the substring from the given string before a
specified number of occurrences of a delimiter.
Returns from the left of the final delimiter if the number is positive and right of
the final delimiter when the number is negative.
If the number is greater than the number of occurrence of delimiter, the returned
substring will be the total string. If the specified number is 0, nothing will be
fetched from the given string.
Example : SELECT SUBSTRING_INDEX('www.mytestpage.info','.',2);
Syntax : SUBSTRING_INDEX(str,delim,count)
Output : www.mytestpage
©w3resource
TRIM()
MySQL TRIM() function returns a string after removing all prefixes or suffixes from
the given string.
Example : SELECT TRIM(' trim ');
Syntax : TRIM([{BOTH | LEADING | TRAILING} [remstr] FROM] str)
Output : trim (leading and trailing space removed)
Example : SELECT TRIM(LEADING 'leading' FROM 'leadingtext' );
Output : text
Example : SELECT TRIM(BOTH 'leadtrail' FROM 'leadtrailtextleadtrail');
Output : text
©w3resource
UNHEX()
MySQL UNHEX() function performs the opposite operation of HEX(). This function
interprets each pair of hexadecimal digits (in the argument) as a number and
converts it to a character.
Example : SELECT UNHEX('4D7953514C');
Syntax : UNHEX(str)
Output : MySQL
Example : SELECT UNHEX(HEX('MySQL'));
Output : MySQL
©w3resource
UPPER()
MySQL UPPER() converts all the characters in a string to uppercase characters.
Example : SELECT UPPER('myteststring');
Syntax : UPPER(str)
Output : MYTESTSTRING
©w3resource
Thank you for your Time and
Attention!
©w3resource

More Related Content

Similar to MySQL String Functions.pptx (20)

Unit 2
Unit 2Unit 2
Unit 2
 
Lesson in Strings for C Programming Lessons
Lesson in Strings for C Programming LessonsLesson in Strings for C Programming Lessons
Lesson in Strings for C Programming Lessons
 
String function in my sql
String function in my sqlString function in my sql
String function in my sql
 
STRINGS IN C MRS.SOWMYA JYOTHI.pdf
STRINGS IN C MRS.SOWMYA JYOTHI.pdfSTRINGS IN C MRS.SOWMYA JYOTHI.pdf
STRINGS IN C MRS.SOWMYA JYOTHI.pdf
 
Strings
StringsStrings
Strings
 
Strings.ppt
Strings.pptStrings.ppt
Strings.ppt
 
Mysql1
Mysql1Mysql1
Mysql1
 
Unitii string
Unitii stringUnitii string
Unitii string
 
14 ruby strings
14 ruby strings14 ruby strings
14 ruby strings
 
String and string buffer
String and string bufferString and string buffer
String and string buffer
 
Unit3 C
Unit3 C Unit3 C
Unit3 C
 
Strings in Python
Strings in PythonStrings in Python
Strings in Python
 
Mysql
MysqlMysql
Mysql
 
Mysql
MysqlMysql
Mysql
 
Mysql
MysqlMysql
Mysql
 
Strings
StringsStrings
Strings
 
Variables In Php 1
Variables In Php 1Variables In Php 1
Variables In Php 1
 
The Ring programming language version 1.5.3 book - Part 35 of 184
The Ring programming language version 1.5.3 book - Part 35 of 184The Ring programming language version 1.5.3 book - Part 35 of 184
The Ring programming language version 1.5.3 book - Part 35 of 184
 
Strings in c++
Strings in c++Strings in c++
Strings in c++
 
Array, string and pointer
Array, string and pointerArray, string and pointer
Array, string and pointer
 

Recently uploaded

BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptxBSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptxfenichawla
 
UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSISrknatarajan
 
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...Call Girls in Nagpur High Profile
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Call Girls in Nagpur High Profile
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...ranjana rawat
 
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingUNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingrknatarajan
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VDineshKumar4165
 
Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01KreezheaRecto
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlysanyuktamishra911
 
UNIT-IFLUID PROPERTIES & FLOW CHARACTERISTICS
UNIT-IFLUID PROPERTIES & FLOW CHARACTERISTICSUNIT-IFLUID PROPERTIES & FLOW CHARACTERISTICS
UNIT-IFLUID PROPERTIES & FLOW CHARACTERISTICSrknatarajan
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordAsst.prof M.Gokilavani
 
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Christo Ananth
 
PVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELL
PVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELLPVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELL
PVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELLManishPatel169454
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Bookingdharasingh5698
 
result management system report for college project
result management system report for college projectresult management system report for college project
result management system report for college projectTonystark477637
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdfankushspencer015
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . pptDineshKumar4165
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Dr.Costas Sachpazis
 

Recently uploaded (20)

(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
 
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptxBSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
 
UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSIS
 
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
 
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
 
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingUNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - V
 
Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghly
 
UNIT-IFLUID PROPERTIES & FLOW CHARACTERISTICS
UNIT-IFLUID PROPERTIES & FLOW CHARACTERISTICSUNIT-IFLUID PROPERTIES & FLOW CHARACTERISTICS
UNIT-IFLUID PROPERTIES & FLOW CHARACTERISTICS
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
 
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
 
PVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELL
PVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELLPVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELL
PVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELL
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
 
result management system report for college project
result management system report for college projectresult management system report for college project
result management system report for college project
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdf
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . ppt
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
 

MySQL String Functions.pptx

  • 3. ASCII() This function returns the numeric value of the leftmost character of the string str. Returns 0 if str is the empty string. Returns NULL if str is NULL Syntax : ASCII(str) Example : SELECT ASCII('2'); Output : 50 Example : SELECT ASCII(2); Output : 50 Example : SELECT ASCII(‘An’); Output : 65 ©w3resource
  • 4. BIN() Returns a string representation of the binary value of N, where N is a longlong (BIGINT) number. Returns NULL if N is NULL. Syntax : BIN(N) Example : SELECT BIN(12); Output : 1100 ©w3resource
  • 5. BIT_LENGTH() Returns the length of the string str in bits. Syntax : BIT_LENGTH(str) Example : SELECT BIT_LENGTH('text'); Output : 32 ©w3resource
  • 6. CHAR() CHAR() interprets each argument N as an integer and returns a string consisting of the characters given by the code values of those integers. NULL values are skipped. Syntax : CHAR(N,... [USING charset_name]) Example : SELECT CHAR(77,121,83,81,'76'); Output : MySQL Example : SELECT CHAR(77,77.3,'77.3'); Output : MMM ©w3resource
  • 7. CHAR_LENGTH() Returns the length of the string str, measured in characters. A multi-byte character counts as a single character. This means that for a string containing five 2-byte characters, LENGTH() returns 10, whereas CHAR_LENGTH() returns 5. Syntax : CHAR_LENGTH(str) Example : SELECT CHAR_LENGTH('test string'); Output : 11 ©w3resource
  • 8. CONCAT() Returns the string that results from concatenating one or more arguments. If all arguments are nonbinary strings, the result is a nonbinary string. If the arguments include any binary strings, the result is a binary string. A numeric argument is converted to its equivalent nonbinary string form. Syntax : CONCAT(str1,str2,...) Example : SELECT CONCAT('w3resource','.','com'); Output : w3resource.com ©w3resource
  • 9. 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 ©w3resource
  • 10. 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 ©w3resource
  • 11. 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 ©w3resource
  • 12. 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 ©w3resource
  • 13. 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 ©w3resource
  • 14. FORMAT() Formats the number X to a format like '#,###,###.##', rounded to D decimal places, and returns the result as a string. If D is 0, the result has no decimal point or fractional part. Syntax : FORMAT(X,D) Example : SELECT FORMAT(12332.123456, 4); Output : 12,332.1235 Example : SELECT FORMAT(12332.1,4); Output : 12,332.1000 Example : SELECT FORMAT(12332.2,0); Output : 12,332 ©w3resource
  • 15. HEX() MySQL HEX() returns a string representation of hexadecimal value of a decimal or string value specified as argument. If the argument is a string, each character in the argument is converted to two hexadecimal digits. If the argument is decimal, the function returns a hexadecimal string representation of the argument , and treated as a longlong(BIGINT) number. Syntax : HEX(str), HEX(N) Example : SELECT HEX(157); Output : 9D ©w3resource
  • 16. INSERT() Returns the string str, with the substring beginning at position pos and len characters long replaced by the string newstr. Returns the original string if pos is not within the length of the string. Replaces the rest of the string from position pos if len is not within the length of the rest of the string. Syntax : INSERT(str,pos,len,newstr) Example : SELECT INSERT('Originalstring', 4, 5, ' insert '); Output : Ori insert string Example : SELECT INSERT('Originalstring', -3, 5, ' insert '); Output : Originalstring ©w3resource
  • 17. INSTR() MySQL INSTR() takes a string and a substring of it as arguments, and returns an integer which indicates the position of the first occurrence of the substring within the string Syntax : INSTR(str,substr) Example : SELECT INSTR('myteststring','st'); Output : 5 ©w3resource
  • 18. LCASE() MySQL LCASE() converts the characters of a string to lower case characters. Syntax : LCASE(str) Example : SELECT LCASE('MYTESTSTRING'); Output : myteststring ©w3resource
  • 19. LEFT() MySQL LEFT() returns a specified number of characters from the left of a given string. Both the number and the string are supplied in the arguments as str and len of the function. Syntax : LEFT(str,len) Example : SELECT LEFT('w3resource', 3); Output : w3r ©w3resource
  • 20. LENGTH() MySQL LENGTH() returns the length of a given string. Syntax : LENGTH(str) Example : SELECT LENGTH('text'); Output : 4 ©w3resource
  • 21. LOCATE() MySQL LOCATE() returns the position of the first occurrence of a string within a string. Both of these strings are passed as arguments. An optional argument may be used to specify from which position of the string (i.e. string to be searched) searching will start. If this position is not mentioned, searching starts from the beginning. Syntax : LOCATE(substr,str,pos) Example : SELECT LOCATE('st','myteststring'); Output : 5 ©w3resource
  • 22. LOWER() MySQL LOWER() converts all the characters in a string to lowercase characters. Syntax : LOWER(str) Example : SELECT LOWER('MYTESTSTRING'); Output : myteststring ©w3resource
  • 23. LPAD() MySQL LPAD() left pads a string with another string. The actual string, a number indicating the length of the padding in characters (optional) and the string to be used for left padding - all are passed as arguments. Syntax : LPAD(str,len,padstr) Example : SELECT LPAD('Hello',10,'**'); Output : *****Hello Example : SELECT LPAD('hi',1,'**'); Output : h ©w3resource
  • 24. LTRIM(str) MySQL LTRIM() removes the leading space characters of a string passed as argument. Syntax : LTRIM(str) Example : SELECT LTRIM(' Hello') Output : Hello ( leading spaces have been exclude) ©w3resource
  • 25. 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 ©w3resource
  • 26. 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('w3resource',4,3); Output : eso Syntax : MID(str,pos,len) ©w3resource
  • 27. 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) ©w3resource
  • 28. 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("w3resource"); Output : 119 Syntax : ORD(str) ©w3resource
  • 29. POSITION() MySQL POSITION() returns the position of a substring within a string.. Example : SELECT POSITION("ou" IN "w3resource"); Output : 6 Syntax : POSITION(substr IN str) ©w3resource
  • 30. 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('w3re''source'); Output : 'w3re'source' Syntax : QUOTE(str) ©w3resource
  • 31. 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) ©w3resource
  • 32. REPLACE() MySQL REPLACE() replaces all the occurrences of a substring within a string. Example : SELECT REPLACE('w3resource','ur','r'); Output : w3resorce Syntax : REPLACE(str,from_str,to_str) ©w3resource
  • 33. REVERSE() Returns a given string with the order of the characters reversed. Example : SELECT REVERSE('w3resource'); Output : ecruoser3w Syntax : REVERSE(str) ©w3resource
  • 34. 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) ©w3resource
  • 35. 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) ©w3resource
  • 36. RTRIM() MySQL RTRIM() removes the trailing spaces from a given string. Example : SELECT RTRIM('w3resource '); Output : w3resource (excludes the trailing spaces) Syntax : RTRIM(str) ©w3resource
  • 37. 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 ©w3resource
  • 38. SPACE() MySQL SPACE() returns the string containing a number of spaces as specified in the argument. Example : SELECT 'start', SPACE(10), 'end'; Syntax : SPACE(N) Output : start end SPACE(10) ©w3resource
  • 39. SUBSTR() MySQL SUBSTR() returns the specified number of characters from a particular position of a given string. SUBSTR() is a synonym for SUBSTRING(). Example : SELECT SUBSTR('w3resource',4,3); Syntax : SUBSTR(str,pos,len) Output : eso ©w3resource
  • 40. SUBSTRING() MySQL SUBSTRING() returns a specified number of characters from a particular position of a given string. Example : SELECT SUBSTRING('w3resource',4,3); Syntax : SUBSTRING(str,pos,len) Output : eso Example : SELECT SUBSTRING('w3resource.com',5); Output : source.com Example : SELECT SUBSTRING('w3resource.com',-5); Output : e.com ©w3resource
  • 41. SUBSTRING_INDEX() MySQL SUBSTRING_INDEX() returns the substring from the given string before a specified number of occurrences of a delimiter. Returns from the left of the final delimiter if the number is positive and right of the final delimiter when the number is negative. If the number is greater than the number of occurrence of delimiter, the returned substring will be the total string. If the specified number is 0, nothing will be fetched from the given string. Example : SELECT SUBSTRING_INDEX('www.mytestpage.info','.',2); Syntax : SUBSTRING_INDEX(str,delim,count) Output : www.mytestpage ©w3resource
  • 42. TRIM() MySQL TRIM() function returns a string after removing all prefixes or suffixes from the given string. Example : SELECT TRIM(' trim '); Syntax : TRIM([{BOTH | LEADING | TRAILING} [remstr] FROM] str) Output : trim (leading and trailing space removed) Example : SELECT TRIM(LEADING 'leading' FROM 'leadingtext' ); Output : text Example : SELECT TRIM(BOTH 'leadtrail' FROM 'leadtrailtextleadtrail'); Output : text ©w3resource
  • 43. UNHEX() MySQL UNHEX() function performs the opposite operation of HEX(). This function interprets each pair of hexadecimal digits (in the argument) as a number and converts it to a character. Example : SELECT UNHEX('4D7953514C'); Syntax : UNHEX(str) Output : MySQL Example : SELECT UNHEX(HEX('MySQL')); Output : MySQL ©w3resource
  • 44. UPPER() MySQL UPPER() converts all the characters in a string to uppercase characters. Example : SELECT UPPER('myteststring'); Syntax : UPPER(str) Output : MYTESTSTRING ©w3resource
  • 45. Thank you for your Time and Attention! ©w3resource