SQL UCASE Function
Category : TECH Author : Ankur Rastogi Date : Sun Mar 27 2016 Views : 34

SQL UCASE() function is used to return the column value in upper case while fetching data from database. UCASE function will return only input column in upper case not all columns in that table.
Syntax for UCASE function is
SELECT UCASE(column_name) FROM table_name;
Let us look more into it with the help of an example
Consider table student_list containing details for student.
+-----+------------------+--------+-----------+
| sid | name | year | hostel_id |
+-----+------------------+--------+-----------+
| 1 | Ankur Rastogi | First | 4 |
| 2 | Amit Kumar | Second | 8 |
| 3 | Ram Kumar | Second | 8 |
| 4 | Shiv Saxena | First | 6 |
| 5 | Aman Aggarwal | Third | 3 |
| 6 | Nipun Gupta | Fourth | 2 |
| 7 | Arpit Gupta | Third | 1 |
| 8 | Shantanu Rastogi | Second | 3 |
| 9 | Ramesh Kumar | Third | 1 |
| 10 | Neelima Dhingra | Second | NULL |
| 11 | Anu Sibbal | Third | NULL |
+-----+------------------+--------+-----------+
Let us find the names of all the students and their respective years and name should be in upper case. Query for that will be
SELECT UCASE(name), year FROM student_list;
+------------------+--------+
| UCASE(name) | year |
+------------------+--------+
| ANKUR RASTOGI | First |
| AMIT KUMAR | Second |
| RAM KUMAR | Second |
| SHIV SAXENA | First |
| AMAN AGGARWAL | Third |
| NIPUN GUPTA | Fourth |
| ARPIT GUPTA | Third |
| SHANTANU RASTOGI | Second |
| RAMESH KUMAR | Third |
| NEELIMA DHINGRA | Second |
| ANU SIBBAL | Third |
+------------------+--------+

SQL UCASE() function is used to return the column value in upper case while fetching data from database. UCASE function will return only input column in upper case not all columns in that table.
Syntax for UCASE function is
SELECT UCASE(column_name) FROM table_name;
Let us look more into it with the help of an example
Consider table student_list containing details for student.
+-----+------------------+--------+-----------+
| sid | name | year | hostel_id |
+-----+------------------+--------+-----------+
| 1 | Ankur Rastogi | First | 4 |
| 2 | Amit Kumar | Second | 8 |
| 3 | Ram Kumar | Second | 8 |
| 4 | Shiv Saxena | First | 6 |
| 5 | Aman Aggarwal | Third | 3 |
| 6 | Nipun Gupta | Fourth | 2 |
| 7 | Arpit Gupta | Third | 1 |
| 8 | Shantanu Rastogi | Second | 3 |
| 9 | Ramesh Kumar | Third | 1 |
| 10 | Neelima Dhingra | Second | NULL |
| 11 | Anu Sibbal | Third | NULL |
+-----+------------------+--------+-----------+
Let us find the names of all the students and their respective years and name should be in upper case. Query for that will be
SELECT UCASE(name), year FROM student_list;
+------------------+--------+
| UCASE(name) | year |
+------------------+--------+
| ANKUR RASTOGI | First |
| AMIT KUMAR | Second |
| RAM KUMAR | Second |
| SHIV SAXENA | First |
| AMAN AGGARWAL | Third |
| NIPUN GUPTA | Fourth |
| ARPIT GUPTA | Third |
| SHANTANU RASTOGI | Second |
| RAMESH KUMAR | Third |
| NEELIMA DHINGRA | Second |
| ANU SIBBAL | Third |
+------------------+--------+
Disclaimer: The above content reflect author’s personal views and do not reflect the views of OYEWIKI. Neither OYEWIKI nor any person/organization acting on its behalf is liable to accept any legal liability/responsibility for any error/mislead in this information or any information available on the website. This website in no way accepts the responsibility for any loss, injury, damage, discomfort or inconvenience caused as a result of reliance on any information provided on this website.
If you want to add more comments to the article or you see any thing incorrect please write a comment below and we will surely get back to you.