TechBeamersTechBeamers
  • Learn ProgrammingLearn Programming
    • Python Programming
      • Python Basic
      • Python OOP
      • Python Pandas
      • Python PIP
      • Python Advanced
      • Python Selenium
    • Python Examples
    • Selenium Tutorials
      • Selenium with Java
      • Selenium with Python
    • Software Testing Tutorials
    • Java Programming
      • Java Basic
      • Java Flow Control
      • Java OOP
    • C Programming
    • Linux Commands
    • MySQL Commands
    • Agile in Software
    • AngularJS Guides
    • Android Tutorials
  • Interview PrepInterview Prep
    • SQL Interview Questions
    • Testing Interview Q&A
    • Python Interview Q&A
    • Selenium Interview Q&A
    • C Sharp Interview Q&A
    • PHP Interview Questions
    • Java Interview Questions
    • Web Development Q&A
  • Self AssessmentSelf Assessment
    • Python Test
    • Java Online Test
    • Selenium Quiz
    • Testing Quiz
    • HTML CSS Quiz
    • Shell Script Test
    • C/C++ Coding Test
Search
  • Python Multiline String
  • Python Multiline Comment
  • Python Iterate String
  • Python Dictionary
  • Python Lists
  • Python List Contains
  • Page Object Model
  • TestNG Annotations
  • Python Function Quiz
  • Python String Quiz
  • Python OOP Test
  • Java Spring Test
  • Java Collection Quiz
  • JavaScript Skill Test
  • Selenium Skill Test
  • Selenium Python Quiz
  • Shell Scripting Test
  • Latest Python Q&A
  • CSharp Coding Q&A
  • SQL Query Question
  • Top Selenium Q&A
  • Top QA Questions
  • Latest Testing Q&A
  • REST API Questions
  • Linux Interview Q&A
  • Shell Script Questions
© 2024 TechBeamers. All Rights Reserved.
Reading: MySQL LOWER() and LCASE() Functions
Font ResizerAa
TechBeamersTechBeamers
Font ResizerAa
  • Python
  • SQL
  • C
  • Java
  • Testing
  • Selenium
  • Agile Concepts Simplified
  • Linux
  • MySQL
  • Python Quizzes
  • Java Quiz
  • Testing Quiz
  • Shell Script Quiz
  • WebDev Interview
  • Python Basic
  • Python Examples
  • Python Advanced
  • Python OOP
  • Python Selenium
  • General Tech
Search
  • Programming Tutorials
    • Python Tutorial
    • Python Examples
    • Java Tutorial
    • C Tutorial
    • MySQL Tutorial
    • Selenium Tutorial
    • Testing Tutorial
  • Top Interview Q&A
    • SQL Interview
    • Web Dev Interview
  • Best Coding Quiz
    • Python Quizzes
    • Java Quiz
    • Testing Quiz
    • ShellScript Quiz
Follow US
© 2024 TechBeamers. All Rights Reserved.
MySQL Tutorial

MySQL LOWER() and LCASE() Functions

Last updated: Sep 28, 2023 8:26 pm
By Meenakshi Agarwal
Share
5 Min Read
MySQL LOWER() and LCASE() Functions Explained
MySQL LOWER() and LCASE() Functions Explained
SHARE

This tutorial explains MySQL LOWER()/LCASE() functions which convert the upper case characters of a string to the LOWER case. We’ll describe the functioning of this method with the help of simple examples.

Contents
SyntaxMySQL LOWER()/LCASE() ExamplesUsing LOWER()/LCASE() to convert text to lower caseCalling LOWER()/LCASE() on table fieldsMySQL LOWER()/LCASE() on binary text

1. LOWER()/LCASE() Syntax
2. LOWER()/LCASE() to convert text to lower case
3. LOWER()/LCASE() on table data
4. LOWER()/LCASE() on binary text

Let’s now go through each of the sections one by one.

MySQL LOWER()/LCASE() Functions

As stated initially, LOWER() is a built-in MySQL function that changes a string value to the LOWER case. So, let’s now see the details and check out how can we use it.

Syntax

Below is the signature of this method:

# MySQL Function to convert text to LOWER case
LOWER(Given_string);

Below is the description of the parameter used in the above function.

+--------------+-------------------------------------+
| # Params     | # Description                       |
+--------------+-------------------------------------+
| Given_string | Input string argument in upper case |
+-------------+--------------------------------------+

MySQL also provides LCASE() which is another function to convert a string to the LOWER case. It takes some text input and produces the result in capitalized format.

# Another MySQL function to capitalize a string
LCASE(Given_string);

Later, in examples, you’ll see that both LOWER() and LCASE() are producing a similar output.

MySQL UPPER()/UCASE() Functions

MySQL LOWER()/LCASE() Examples

Let’s now unveil several examples addressing different situations.

Using LOWER()/LCASE() to convert text to lower case

Both LOWER() and LCASE() functions can take a standard or alpha-numeric TEXT and turn to the LOWER case. See the below example.

SELECT LOWER('PYTHON PROGRAMMING');
SELECT LOWER('PYTHON VERSION 3.6');

Check the result/outcome of the LOWER() function below.

1 MySQL Workbench
python programming
python version 3.6

Next, we’ll run the same test using the MySQL LCASE() function.

SELECT LCASE('PYTHON PROGRAMMING');
SELECT LCASE('PYTHON VERSION 3.6');

You can see that LCASE() also produced the same as LOWER() did.

1 MySQL Workbench
python programming
python version 3.6

Calling LOWER()/LCASE() on table fields

In this example, we are applying the LOWER() on a table column. Here, we will print the company name in capital format.

-- Using MySQL LOWER on table data
SELECT 
    company_name, 
    LOWER(company_name) LOWER_CASE
FROM
    company_list
ORDER BY 
    company_name
LIMIT 5;

After executing the above command, the output will be:

1 MySQL Workbench
apple
bing
ca
dell
google

Let’s now use LCASE on the same table and see what it does.

-- Using MySQL LCASE on table data
SELECT 
    company_name, 
    LCASE(company_name) LCASE
FROM
    company_list
ORDER BY 
    company_name
LIMIT 5;

After executing the above command, the output is the same:

1 MySQL Workbench
apple
bing
ca
dell
google

Also Read: MySQL CONCAT to Concatenate Strings

MySQL LOWER()/LCASE() on binary text

MySQL types such as BINARY, VARBINARY, or BLOB are binary data. The LOWER() function is not directly compatible with these.

Hence, we first have to convert them to be compatible with the LOWER() function. See the example below.

-- Convert binary text to string and then in LOWER case using LOWER()
SET @binary_data = BINARY 'BINARY SAMPLE TEXT';
SELECT LOWER(@binary_data), LOWER(CONVERT(@binary_data USING UTF8MB4)) LOWER_FUNC;

After execution, we get this:

1 MySQL Workbench
BINARY SAMPLE TEXT   binary sample text

Similarly, we’ll now use LCASE() instead of LOWER() for the above test case.

-- Convert binary text to string and then in LOWER case using LCASE()
SET @binary_data = BINARY 'BINARY SAMPLE TEXT';
SELECT LCASE(@binary_data), LCASE(CONVERT(@binary_data USING UTF8MB4)) LCASE_FUNC;

After execution, we get this:

1 MySQL Workbench
BINARY SAMPLE TEXT   binary sample text

We hope that after wrapping up this tutorial, you will feel comfortable using the MySQL LOWER() and LCASE() functions. However, you may practice more with examples to gain confidence.

Also, to learn SQL from scratch to depth, read our step-by-step MySQL tutorial.

You Might Also Like

MySQL vs MongoDB Comparison

Concatenate Strings in an SQL Query With Examples

The Difference between UPSERT & Insert

SQL Programming Test in 2024

SQL Table Creation: The Missing Manual

Meenakshi Agarwal Avatar
By Meenakshi Agarwal
Follow:
Hi, I'm Meenakshi Agarwal. I have a Bachelor's degree in Computer Science and a Master's degree in Computer Applications. After spending over a decade in large MNCs, I gained extensive experience in programming, coding, software development, testing, and automation. Now, I share my knowledge through tutorials, quizzes, and interview questions on Python, Java, Selenium, SQL, and C# on my blog, TechBeamers.com.
Previous Article MySQL UPPER() and UCASE() Functions Explained MySQL UPPER() and UCASE() Functions
Next Article MySQL Date and Date Functions Explained MySQL Date and Date Functions

Popular Tutorials

SQL Interview Questions List
50 SQL Practice Questions for Good Results in Interview
SQL Interview Nov 01, 2016
Demo Websites You Need to Practice Selenium
7 Sites to Practice Selenium for Free in 2024
Selenium Tutorial Feb 08, 2016
SQL Exercises with Sample Table and Demo Data
SQL Exercises – Complex Queries
SQL Interview May 10, 2020
Java Coding Questions for Software Testers
15 Java Coding Questions for Testers
Selenium Tutorial Jun 17, 2016
30 Quick Python Programming Questions On List, Tuple & Dictionary
30 Python Programming Questions On List, Tuple, and Dictionary
Python Basic Python Tutorials Oct 07, 2016
//
Our tutorials are written by real people who’ve put in the time to research and test thoroughly. Whether you’re a beginner or a pro, our tutorials will guide you through everything you need to learn a programming language.

Top Coding Tips

  • PYTHON TIPS
  • PANDAS TIPSNew
  • DATA ANALYSIS TIPS
  • SELENIUM TIPS
  • C CODING TIPS
  • GDB DEBUG TIPS
  • SQL TIPS & TRICKS

Top Tutorials

  • PYTHON TUTORIAL FOR BEGINNERS
  • SELENIUM WEBDRIVER TUTORIAL
  • SELENIUM PYTHON TUTORIAL
  • SELENIUM DEMO WEBSITESHot
  • TESTNG TUTORIALS FOR BEGINNERS
  • PYTHON MULTITHREADING TUTORIAL
  • JAVA MULTITHREADING TUTORIAL

Sign Up for Our Newsletter

Subscribe to our newsletter to get our newest articles instantly!

Loading
TechBeamersTechBeamers
Follow US
© 2024 TechBeamers. All Rights Reserved.
  • About
  • Contact
  • Disclaimer
  • Privacy Policy
  • Terms of Use
TechBeamers Newsletter - Subscribe for Latest Updates
Join Us!

Subscribe to our newsletter and never miss the latest tech tutorials, quizzes, and tips.

Loading
Zero spam, Unsubscribe at any time.
x