SlideShare una empresa de Scribd logo
1 de 14
STRING FUNCTION
        IN
       MYSQL
STRING TYPES


 CHAR(M) - A fixed-length string between 1 and 255 characters in
  length (for example CHAR(5)), right-padded with spaces to the
  specified length when stored. Defining a length is not required, but
  the default is 1.

 VARCHAR(M) - A variable-length string between 1 and 255
  characters in length; for example VARCHAR(25). You must define a
  length when creating a VARCHAR field.
String Functions
 CONCAT()      Return concatenated string
 INSTR()       Return the index of the first occurrence of substring
 LCASE()       Synonym for LOWER()
 LEFT()        Return the leftmost number of characters as specified
 LENGTH()      Return the length of a string in bytes
 LOWER()       Return the argument in lowercase
 LTRIM()       Remove leading spaces
 MID()         Return a substring starting from the specified position
 RIGHT()       Return the specified rightmost number of characters
 RTRIM()       Remove trailing spaces
 SUBSTRING(),
              Return the substring as specified
 SUBSTR()
 TRIM()        Remove leading and trailing spaces
 UCASE()       Synonym for UPPER()
 UPPER()       Convert to uppercase
CONCAT(str1,str2,...)

  Returns the string that results from concatenating
  the arguments. May have one or more arguments.
  If all arguments are non-binary strings, the result is
  a non-binary string. If the arguments include any
  binary strings, the result is a binary string. A
  numeric argument is converted to its equivalent
  binary string form; if you want to avoid that, you
  can use an explicit type cast, as in this example:

    mysql> SELECT CONCAT('My', 'S', 'QL');
    +-----------------------------------------------------------------------------+
    | CONTACT (‘My’, ‘S’, ‘QL’)                                                    |
    +-----------------------------------------------------------------------------+
    | MySQL                                                                        |
    +-----------------------------------------------------------------------------+
    1 row in set (0.00 sec)
INSERT(str,pos,len,newstr)

  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. Returns NULL if any argument
  is NULL.

    mysql> SELECT INSERT('Quadratic', 3, 4, 'What');
    +-----------------------------------------------------------------------------+
    | INSERT('Quadratic', 3, 4, 'What')                                            |
    +-----------------------------------------------------------------------------+
    | QuaWhatic                                                                      |
    +-----------------------------------------------------------------------------+
    1 row in set (0.00 sec)
LCASE(str)

  LCASE() is a synonym for LOWER().
  LEFT(str,len)

  Returns the leftmost len characters from the
  string str, or NULL if any argument is NULL.




   mysql> SELECT LEFT('foobarbar', 5);
   +-----------------------------------------------------------------------------+
   | LEFT('foobarbar', 5)                                                        |
   +-----------------------------------------------------------------------------+
   | fooba                                                                        |
   +-----------------------------------------------------------------------------+
   1 row in set (0.00 sec)
LENGTH(str)

  Returns the length of the string str, measured in
  bytes. A multi-byte character counts as
  multiple bytes. This means that for a string
  containing five two-byte characters, LENGTH()
  returns 10, whereas CHAR_LENGTH() returns 5.




                      LENGTH('text');

     LENGTH('text')

     4
LOWER(str)

  Returns the string str with all characters
  changed to lowercase according to the
  current character set mapping.




                     LOWER(‘QUADRATICALLY');

     LOWER(‘QUADRATICALLY')

     quadratically
LTRIM(str)

   Returns the string str with leading space
   characters removed.




                  LTRIM(‘ barbar’);

     LTRIM(‘ barbar')

      barbar
RIGHT(str,len)

  Returns the rightmost len characters from the
  string str, or NULL if any argument is NULL.




                  RIGHT (‘foobarbar’);

     RIGHT(‘foobarbar')

     rbar
MID(str,pos,len) and
  SUBSTRING(str , pos, len)
The forms without a len argument return a substring from
string str starting at position pos. The forms with a len
argument return a substring len characters long from string
str, starting at position pos. The forms that use FROM are
standard SQL syntax. It is also possible to use a negative
value for pos. In this case, the beginning of the substring is
pos characters from the end of the string, rather than the
beginning. A negative value may be used for pos in any of
the forms of this function.
                        SUBSTRING(‘quadratically’, 5, 6);

          SUBSTRING(‘quadratically’, 5, 6)

          ratica
TRIM([remstr FROM] str)

  Returns the string str with all remstr prefixes or
  suffixes removed. If none of the specifiers BOTH,
  LEADING, or TRAILING is given, BOTH is
  assumed. remstr is optional and, if not
  specified, spaces are removed.




                 TRIM(‘ bar ‘);

     TRIM(‘ bar ‘)

     bar
UCASE(str) and UPPER(str)

  • UCASE() is a synonym for UPPER().

  • Returns the string str with all characters
    changed to uppercase according to the
    current character set mapping.




                  UPPER('Allah-hus-samad');

     UPPER('Allah-hus-samad')

     ALLAH-HUS-SAMAD
THANK YOU

Más contenido relacionado

La actualidad más candente

Introduction to structured query language (sql)
Introduction to structured query language (sql)Introduction to structured query language (sql)
Introduction to structured query language (sql)Sabana Maharjan
 
introdution to SQL and SQL functions
introdution to SQL and SQL functionsintrodution to SQL and SQL functions
introdution to SQL and SQL functionsfarwa waqar
 
MySQL 5.7 String Functions
MySQL 5.7 String FunctionsMySQL 5.7 String Functions
MySQL 5.7 String FunctionsFrancesco Marino
 
SQL Functions and Operators
SQL Functions and OperatorsSQL Functions and Operators
SQL Functions and OperatorsMohan Kumar.R
 
SQL BUILT-IN FUNCTION
SQL BUILT-IN FUNCTIONSQL BUILT-IN FUNCTION
SQL BUILT-IN FUNCTIONArun Sial
 
Sql group functions
Sql group functionsSql group functions
Sql group functionsSumit Tambe
 
SQL, Embedded SQL, Dynamic SQL and SQLJ
SQL, Embedded SQL, Dynamic SQL and SQLJSQL, Embedded SQL, Dynamic SQL and SQLJ
SQL, Embedded SQL, Dynamic SQL and SQLJDharita Chokshi
 
Aggregate functions in SQL.pptx
Aggregate functions in SQL.pptxAggregate functions in SQL.pptx
Aggregate functions in SQL.pptxSherinRappai
 
Group By, Order By, and Aliases in SQL
Group By, Order By, and Aliases in SQLGroup By, Order By, and Aliases in SQL
Group By, Order By, and Aliases in SQLMSB Academy
 

La actualidad más candente (20)

SQL Overview
SQL OverviewSQL Overview
SQL Overview
 
SQL Functions
SQL FunctionsSQL Functions
SQL Functions
 
Introduction to structured query language (sql)
Introduction to structured query language (sql)Introduction to structured query language (sql)
Introduction to structured query language (sql)
 
introdution to SQL and SQL functions
introdution to SQL and SQL functionsintrodution to SQL and SQL functions
introdution to SQL and SQL functions
 
MySQL 5.7 String Functions
MySQL 5.7 String FunctionsMySQL 5.7 String Functions
MySQL 5.7 String Functions
 
Sql operator
Sql operatorSql operator
Sql operator
 
SQL Join Basic
SQL Join BasicSQL Join Basic
SQL Join Basic
 
DBMS Notes: DDL DML DCL
DBMS Notes: DDL DML DCLDBMS Notes: DDL DML DCL
DBMS Notes: DDL DML DCL
 
SQL Functions and Operators
SQL Functions and OperatorsSQL Functions and Operators
SQL Functions and Operators
 
Oracle Database Sequence
Oracle Database SequenceOracle Database Sequence
Oracle Database Sequence
 
MySQL Functions
MySQL FunctionsMySQL Functions
MySQL Functions
 
Sql operators & functions 3
Sql operators & functions 3Sql operators & functions 3
Sql operators & functions 3
 
Aggregate function
Aggregate functionAggregate function
Aggregate function
 
AGGREGATE FUNCTION.pptx
AGGREGATE FUNCTION.pptxAGGREGATE FUNCTION.pptx
AGGREGATE FUNCTION.pptx
 
SQL BUILT-IN FUNCTION
SQL BUILT-IN FUNCTIONSQL BUILT-IN FUNCTION
SQL BUILT-IN FUNCTION
 
SQL
SQLSQL
SQL
 
Sql group functions
Sql group functionsSql group functions
Sql group functions
 
SQL, Embedded SQL, Dynamic SQL and SQLJ
SQL, Embedded SQL, Dynamic SQL and SQLJSQL, Embedded SQL, Dynamic SQL and SQLJ
SQL, Embedded SQL, Dynamic SQL and SQLJ
 
Aggregate functions in SQL.pptx
Aggregate functions in SQL.pptxAggregate functions in SQL.pptx
Aggregate functions in SQL.pptx
 
Group By, Order By, and Aliases in SQL
Group By, Order By, and Aliases in SQLGroup By, Order By, and Aliases in SQL
Group By, Order By, and Aliases in SQL
 

Similar a String function in my sql

MySQL String Functions.docx
MySQL String Functions.docxMySQL String Functions.docx
MySQL String Functions.docxRUBAB79
 
string functions in SQL ujjwal matoliya.pptx
string functions in SQL ujjwal matoliya.pptxstring functions in SQL ujjwal matoliya.pptx
string functions in SQL ujjwal matoliya.pptxujjwalmatoliya
 
Regular Expression Patterns
Regular Expression PatternsRegular Expression Patterns
Regular Expression PatternsDuane Bodle
 
SQL for pattern matching (Oracle 12c)
SQL for pattern matching (Oracle 12c)SQL for pattern matching (Oracle 12c)
SQL for pattern matching (Oracle 12c)Logan Palanisamy
 
Postgresql 9.3 overview
Postgresql 9.3 overviewPostgresql 9.3 overview
Postgresql 9.3 overviewAveic
 
String in programming language in c or c++
String in programming language in c or c++String in programming language in c or c++
String in programming language in c or c++Azeemaj101
 
Intro to tsql unit 10
Intro to tsql   unit 10Intro to tsql   unit 10
Intro to tsql unit 10Syed Asrarali
 
stringsinpython-181122100212.pdf
stringsinpython-181122100212.pdfstringsinpython-181122100212.pdf
stringsinpython-181122100212.pdfpaijitk
 
Handling of character strings C programming
Handling of character strings C programmingHandling of character strings C programming
Handling of character strings C programmingAppili Vamsi Krishna
 
The Ring programming language version 1.9 book - Part 123 of 210
The Ring programming language version 1.9 book - Part 123 of 210The Ring programming language version 1.9 book - Part 123 of 210
The Ring programming language version 1.9 book - Part 123 of 210Mahmoud Samir Fayed
 
sql functions3 (1).pdf
sql functions3 (1).pdfsql functions3 (1).pdf
sql functions3 (1).pdfUsha570012
 
String and string buffer
String and string bufferString and string buffer
String and string bufferkamal kotecha
 

Similar a String function in my sql (20)

MySQL String Functions.pptx
MySQL String Functions.pptxMySQL String Functions.pptx
MySQL String Functions.pptx
 
MySQL String Functions.docx
MySQL String Functions.docxMySQL String Functions.docx
MySQL String Functions.docx
 
string functions in SQL ujjwal matoliya.pptx
string functions in SQL ujjwal matoliya.pptxstring functions in SQL ujjwal matoliya.pptx
string functions in SQL ujjwal matoliya.pptx
 
Regular Expression Patterns
Regular Expression PatternsRegular Expression Patterns
Regular Expression Patterns
 
Mysql1
Mysql1Mysql1
Mysql1
 
SQL for pattern matching (Oracle 12c)
SQL for pattern matching (Oracle 12c)SQL for pattern matching (Oracle 12c)
SQL for pattern matching (Oracle 12c)
 
Postgresql 9.3 overview
Postgresql 9.3 overviewPostgresql 9.3 overview
Postgresql 9.3 overview
 
String in programming language in c or c++
String in programming language in c or c++String in programming language in c or c++
String in programming language in c or c++
 
Intro to tsql unit 10
Intro to tsql   unit 10Intro to tsql   unit 10
Intro to tsql unit 10
 
Strings
StringsStrings
Strings
 
Functions
FunctionsFunctions
Functions
 
stringsinpython-181122100212.pdf
stringsinpython-181122100212.pdfstringsinpython-181122100212.pdf
stringsinpython-181122100212.pdf
 
Handling of character strings C programming
Handling of character strings C programmingHandling of character strings C programming
Handling of character strings C programming
 
lecture5.ppt
lecture5.pptlecture5.ppt
lecture5.ppt
 
The Ring programming language version 1.9 book - Part 123 of 210
The Ring programming language version 1.9 book - Part 123 of 210The Ring programming language version 1.9 book - Part 123 of 210
The Ring programming language version 1.9 book - Part 123 of 210
 
5. string
5. string5. string
5. string
 
sql functions3 (1).pdf
sql functions3 (1).pdfsql functions3 (1).pdf
sql functions3 (1).pdf
 
Strings
StringsStrings
Strings
 
String and string buffer
String and string bufferString and string buffer
String and string buffer
 
Python data handling
Python data handlingPython data handling
Python data handling
 

Último

Science 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxScience 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxMaryGraceBautista27
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...Postal Advocate Inc.
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxBarangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxCarlos105
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17Celine George
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYKayeClaireEstoconing
 
Karra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxKarra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxAshokKarra1
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designMIPLM
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Jisc
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceSamikshaHamane
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parentsnavabharathschool99
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Celine George
 
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONHumphrey A Beña
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)lakshayb543
 

Último (20)

Science 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxScience 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptx
 
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptxLEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxBarangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
 
Karra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxKarra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptx
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-design
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in Pharmacovigilance
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parents
 
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptxYOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
 
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
 

String function in my sql

  • 1. STRING FUNCTION IN MYSQL
  • 2. STRING TYPES  CHAR(M) - A fixed-length string between 1 and 255 characters in length (for example CHAR(5)), right-padded with spaces to the specified length when stored. Defining a length is not required, but the default is 1.  VARCHAR(M) - A variable-length string between 1 and 255 characters in length; for example VARCHAR(25). You must define a length when creating a VARCHAR field.
  • 3. String Functions CONCAT() Return concatenated string INSTR() Return the index of the first occurrence of substring LCASE() Synonym for LOWER() LEFT() Return the leftmost number of characters as specified LENGTH() Return the length of a string in bytes LOWER() Return the argument in lowercase LTRIM() Remove leading spaces MID() Return a substring starting from the specified position RIGHT() Return the specified rightmost number of characters RTRIM() Remove trailing spaces SUBSTRING(), Return the substring as specified SUBSTR() TRIM() Remove leading and trailing spaces UCASE() Synonym for UPPER() UPPER() Convert to uppercase
  • 4. CONCAT(str1,str2,...) Returns the string that results from concatenating the arguments. May have one or more arguments. If all arguments are non-binary strings, the result is a non-binary string. If the arguments include any binary strings, the result is a binary string. A numeric argument is converted to its equivalent binary string form; if you want to avoid that, you can use an explicit type cast, as in this example: mysql> SELECT CONCAT('My', 'S', 'QL'); +-----------------------------------------------------------------------------+ | CONTACT (‘My’, ‘S’, ‘QL’) | +-----------------------------------------------------------------------------+ | MySQL | +-----------------------------------------------------------------------------+ 1 row in set (0.00 sec)
  • 5. INSERT(str,pos,len,newstr) 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. Returns NULL if any argument is NULL. mysql> SELECT INSERT('Quadratic', 3, 4, 'What'); +-----------------------------------------------------------------------------+ | INSERT('Quadratic', 3, 4, 'What') | +-----------------------------------------------------------------------------+ | QuaWhatic | +-----------------------------------------------------------------------------+ 1 row in set (0.00 sec)
  • 6. LCASE(str) LCASE() is a synonym for LOWER(). LEFT(str,len) Returns the leftmost len characters from the string str, or NULL if any argument is NULL. mysql> SELECT LEFT('foobarbar', 5); +-----------------------------------------------------------------------------+ | LEFT('foobarbar', 5) | +-----------------------------------------------------------------------------+ | fooba | +-----------------------------------------------------------------------------+ 1 row in set (0.00 sec)
  • 7. LENGTH(str) Returns the length of the string str, measured in bytes. A multi-byte character counts as multiple bytes. This means that for a string containing five two-byte characters, LENGTH() returns 10, whereas CHAR_LENGTH() returns 5. LENGTH('text'); LENGTH('text') 4
  • 8. LOWER(str) Returns the string str with all characters changed to lowercase according to the current character set mapping. LOWER(‘QUADRATICALLY'); LOWER(‘QUADRATICALLY') quadratically
  • 9. LTRIM(str) Returns the string str with leading space characters removed. LTRIM(‘ barbar’); LTRIM(‘ barbar') barbar
  • 10. RIGHT(str,len) Returns the rightmost len characters from the string str, or NULL if any argument is NULL. RIGHT (‘foobarbar’); RIGHT(‘foobarbar') rbar
  • 11. MID(str,pos,len) and SUBSTRING(str , pos, len) The forms without a len argument return a substring from string str starting at position pos. The forms with a len argument return a substring len characters long from string str, starting at position pos. The forms that use FROM are standard SQL syntax. It is also possible to use a negative value for pos. In this case, the beginning of the substring is pos characters from the end of the string, rather than the beginning. A negative value may be used for pos in any of the forms of this function. SUBSTRING(‘quadratically’, 5, 6); SUBSTRING(‘quadratically’, 5, 6) ratica
  • 12. TRIM([remstr FROM] str) Returns the string str with all remstr prefixes or suffixes removed. If none of the specifiers BOTH, LEADING, or TRAILING is given, BOTH is assumed. remstr is optional and, if not specified, spaces are removed. TRIM(‘ bar ‘); TRIM(‘ bar ‘) bar
  • 13. UCASE(str) and UPPER(str) • UCASE() is a synonym for UPPER(). • Returns the string str with all characters changed to uppercase according to the current character set mapping. UPPER('Allah-hus-samad'); UPPER('Allah-hus-samad') ALLAH-HUS-SAMAD