Informatics Practices
Class XII ( Asper
CBSEBoard)
Chapter 3
Database query using sql–
functions and data reporting
Visit : python.mykvs.in for regularupdates
New
syllabus
2023-24
SQL functions
Textfunctions-Performoperationoverstringvalues.
UPPER()–UPPER(str)
Returnsthestringstrwithallcharacterschangedtouppercase.
mysql>SELECTUPPER(‘Tej');
->‘TEJ'
UCASE(str)-UCASE() is a synonym for UPPER().
LOWER(str)-Returns the string strwith all characters changed to
lowercase
mysql> SELECT LOWER('QUADRATICALLY');
-> 'quadratically’
LCASE(str)
LCASE() is a synonym for LOWER().
Visit : python.mykvs.in for regular updates
SQL functions
Textfunctions-Performoperationoverstringvalues.
SUBSTRING(str,pos)-SUBSTRING(strFROMpos),
SUBSTRING(str,pos,len)-SUBSTRING(strFROMposFORlen)
Theformswithoutalenargumentreturnasubstringfromstringstrstartingatpositionpos.Theformswitha
lenargumentreturnasubstringlencharacterslongfromstringstr,startingatpositionpos.Theformsthatuse
FROMarestandardSQLsyntax.Itisalsopossibletouseanegativevalueforpos.Inthiscase,thebeginningof
thesubstringisposcharactersfromtheendofthestring,ratherthanthebeginning.
mysql>SELECTSUBSTRING(‘practically',5);
->'tically'
mysql>SELECTSUBSTRING('foofarbar'FROM4);
->‘farbar'
mysql>SELECTSUBSTRING('Quadratically',5,6);
->'ratica'
mysql>SELECTSUBSTRING(‘Aakila',-3);
->'ila'
mysql>SELECTSUBSTRING(‘Aakila',-5,3);
->'aki'
mysql>SELECTSUBSTRING(‘Aakila'FROM-4FOR2);
->'ki'
MID(str,pos,len)
MID(str,pos,len) is a synonym for
SUBSTRING(str,pos,len),substr()
Visit : python.mykvs.in for regular updates
SQL functions
Textfunctions-Performoperationoverstringvalues.
LTRIM(str)-Returnsthestringstrwithleadingspacecharactersremoved.
mysql>SELECTLTRIM('Toolbar');
->‘Toolbar‘
RTRIM(str)-Returnsthestringstrwithtrailingspacecharactersremoved.
mysql>SELECTRTRIM(‘Toolbar');
->‘Toolbar‘
TRIM([{BOTH | LEADING | TRAILING} [remstr] FROM] str)-Returns the string strwith all
remstrprefixes or suffixes removed. If none of the specifiersBOTH, LEADING, or TRAILING is
given , BOTH is assumed.
mysql> SELECT TRIM(' tool ');
->'bar'
mysql>SELECTTRIM(LEADING'x'FROM'xxxtoolxxx');
->‘toolxxx'
mysql>SELECTTRIM(BOTH'x'FROM'xxxtoolxxx');
->‘tool'
mysql>SELECTTRIM(TRAILING'xyz'FROM‘toolxxx');
->‘tool'
Visit : python.mykvs.in for regular updates