SQL In-built Functions Part-2


SQL Functions | Academy4Code.com
  • What is SQL Left() Function?

LEFT function allows you to extract a substring from a string, starting from the left-most character.

In simple word left function will be return the string started from left side an Syntax or a string,

Syntax: LEFT (String, Number of characters)

Example:

Left SQL Function- Academy4Code
Left SQL Function- Academy4Code

The above query return 7 character from the left side.

If we define the string length from left to 30 or more etc. character but there is only 16 character available in an Syntaxthen it will be display whole string without adding any space.

Let See example below:

Left SQL Function - Acdemy4Code
Left SQL Function – Acdemy4Code

 

  • What is SQL Right() Function?

Right function allows you to extract a substring from a string, starting from the Right-most character.

In simple word right function will be return the string started from right side an Syntax or a string,

Syntax: RIGHT (String, Number of characters)

Example:

Right SQL Function - Acdemy4Code
Right SQL Function – Acdemy4Code

The above query returns the first 4 character from the right side.

Right SQL Function - Acdemy4Code
Right SQL Function – Acdemy4Code

If we define the string length from left to 40 or more etc. character but there is only 12 character available in an Syntax then it will be display whole string without adding any space.

  • What is SQL Lower() Function?

The LOWER function converts all letters in the specified string to lowercase. If there are characters in the string that are not letters, they are unaffected by this function.

Lower SQL Function - Acdemy4Code
Lower SQL Function – Acdemy4Code

The above query returns the all CAPITAL String to Lower string.

  • What is LTRIM() Function?

LTRIM function removes all space characters from the left-hand side of a string.

Syntax: LTRIM(String);

LTRIM SQL Function - Acdemy4Code
LTRIM SQL Function – Acdemy4Code

The above query returns the string value after remove the space from the left side of the string.

  • What is RTRIM() Function?

RTRIM function removes all space characters from the right-hand side of a string.

Syntax: RTRIM(String)

RTRIM SQL Function - Acdemy4Code
RTRIM SQL Function – Acdemy4Code

 

 

 

 

 

 

The above query returns the string with left space but removes the space from the right side of the string.

Continue – To Part – 3(SQL In-built Functions Part-3)

Thanks for reading the article.

Please loud at us, if you have any query over write at ravindra@academy4Code.com /academy4code@gmail.com

Ravindra Kumar is a Programmer and an independent consultant from India. He has been a part of the industry for more than 6 years. During his career, he has worked on mutiple projects of the USA and of India (Technology Evangelist at Microsoft). He received his Bachelors of Engineering from Punjan Technical University. He has been a regular speaker of SQL Sessions in Indian IT Company.

For more, you can consult at ravindra@Academy4Code.com