Home » SQL

Use of UCASE(), LCASE() and MID() functions in SQL

In this article, we are going to discuss about the use of Upper Case, Lower Case and Mid function in SQL.
Submitted by Bharti Parmar, on January 30, 2019

Upper Case, Lower Case and MID functions are scalar functions which return a single value, based in the input value.

As you all know sometimes different databases have not more but, have some minor changes in their syntax's. Similarly, for convert a field value to the upper case, lower case and for MID value different syntax are there for the different database:

Table: Let, we have a table name STUDENT

Table example for ucase, lcase and mid functions

1) UCASE() function

This function is used to converts a field value to upper case.

SYNTAX:

SELECT UCASE(column_name) FROM table_name;
SELECT UPPER(column_name) FROM table_name;

Example:

UCASE() function example in SQL

2) LCASE() function

This function is used to converts a field value to lower case.

SYNTAX:

SELECT LCASE(column_name) FROM table_name;
SELECT LOWER(column_name) FROM table_name;

Example:

LCASE() function example in SQL

3) MID() function

This function is used to extract the char from a text field.

SYNTAX:

SELECT MID(column_name,start,length) AS some_name FROM table_name;

column_name, start, length are the required parameters in MID() function. It is used to extract values of a field.

Where,

  • column_name - is used to extract char.
  • start - shows the starting point like 0 or 1.
  • length - is to return the number of character.

AND,

SUBSTRING() function is also used to extract MID() value. Basically, this SUBSTRING() function is used in SQL Server.

SYNTAX:

SELECT SUBSTRING(column_name,start,length) AS name FROM table_name;

Conclusion:

In this article, we have learned how to use UCASE(), LCASE() and MID() functions in SQL and SQL queries? We will know more about different or use of another scalar function in SQL. Have a great day! Happy Learning!



Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.