
- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Use MySQL concat() and lower() effectively
The contact() method is used to concatenate. However, lower() is used to change the case to lowercase. For our example, let us create a table.
The query to create a table is as follows
mysql> create table concatAndLowerDemo -> ( -> FirstValue varchar(10), -> SecondValue varchar(10), -> ThirdValue varchar(10), -> FourthValue varchar(10) -> ); Query OK, 0 rows affected (0.55 sec)
Now you can insert some records in the table using insert command.
The query is as follows
mysql> insert into concatAndLowerDemo values('John','12345','Java','MySQL'); Query OK, 1 row affected (0.21 sec) mysql> insert into concatAndLowerDemo values('Hi','12345','98764','MongoDB'); Query OK, 1 row affected (0.24 sec) mysql> insert into concatAndLowerDemo values('9485','746464','903940','cpp'); Query OK, 1 row affected (0.15 sec)
Display all records from the table using select statement.
The query is as follows
mysql> select *from concatAndLowerDemo;
The following is the output
+------------+-------------+------------+-------------+ | FirstValue | SecondValue | ThirdValue | FourthValue | +------------+-------------+------------+-------------+ | John | 12345 | Java | MySQL | | Hi | 12345 | 98764 | MongoDB | | 9485 | 746464 | 903940 | cpp | +------------+-------------+------------+-------------+ 3 rows in set (0.00 sec)
Here is the query to use concat() and lower() in the same query
mysql> select lower(concat(FirstValue,SecondValue,ThirdValue,FourthValue)) AS lowerDemo from concatAndLowerDemo;
The following is the output
+---------------------+ | lowerDemo | +---------------------+ | john12345javamysql | | hi1234598764mongodb | | 9485746464903940cpp | +---------------------+ 3 rows in set (0.00 sec)
- Related Questions & Answers
- How to use GROUP_CONCAT in CONCAT in MySQL?
- MySQL query to select multiple rows effectively?
- Can we use “LIKE concat()” in a MySQL query?
- Concat a field in MySQL SELECT?
- MySQL GROUP BY and CONCAT() to display distinct first and last name
- Rename all tables and columns to lower case in MySQL?
- Concat a string to SELECT * in MySQL?
- Perform complex MySQL insert by using CONCAT()?
- Getting last value in MySQL group concat?
- Using Iterations in Python Effectively
- Lower case column names with MySQL SELECT?
- Is there any alternative for CONCAT() in MySQL?
- MySQL query to group concat distinct by Id?
- concat(), replace(), and trim() Strings in Java.
- Difference between concat() and + operator in Java
Advertisements