- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Select Statement to retrieve the same first names with similar last name (but different case) using MySQL?
Let us first create a table −
mysql> create table DemoTable623 (FirstName varchar(100),LastName varchar(100),Age int); Query OK, 0 rows affected (0.76 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable623 values('John','Smith',23); Query OK, 1 row affected (0.66 sec) mysql> insert into DemoTable623 values('Adam','smith',23); Query OK, 1 row affected (0.26 sec) mysql> insert into DemoTable623 values('Chris','Brown',24); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable623 values('Robert','brown',21); Query OK, 1 row affected (0.22 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable623;
This will produce the following output −
+-----------+----------+------+ | FirstName | LastName | Age | +-----------+----------+------+ | John | Smith | 23 | | Adam | smith | 23 | | Chris | Brown | 24 | | Robert | brown | 21 | +-----------+----------+------+ 4 rows in set (0.00 sec)
Here is the query to select statement using MySQL −
mysql> select FirstName from DemoTable623 where lower(LastName) ='smith';
This will produce the following output −
+-----------+ | FirstName | +-----------+ | John | | Adam | +-----------+ 2 rows in set (0.00 sec)
- Related Articles
- Lower case column names with MySQL SELECT?
- Get table names using SELECT statement in MySQL?
- MySQL case statement inside a select statement?
- Display records where first and last name begins with the same letter in MySQL
- Select count of values (Yes, No) with same ids but different corresponding records in MySQL?
- Change value from 1 to Y in MySQL Select Statement using CASE?
- Return similar names from different columns with distinct space allocations in MySQL?
- How MySQL NULLIF() control flow function is similar to CASE statement?
- How to select first and last row record using LIMIT in MySQL?
- Using the value of an alias inside the same MySQL SELECT statement
- Using CASE statement in MySQL to display custom name for empty value
- How to separate last name and first names in single column into two new columns in MySQL?
- Delete rows with duplicate and similar content & get row with maximum number with MySQL select statement?
- Split First name and Last name using JavaScript?
- How to select different values from same column and display them in different columns with MySQL?

Advertisements