

- 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
Get the names beginning with a particular character using LIKE in MySQL
To get the names beginning with a particular character, you need to use LIKE. Let us first create a table:
mysql> create table DemoTable ( StudentFirstName varchar(20) ); Query OK, 0 rows affected (1.01 sec)
Following is the query to insert some records in the table using insert command:
mysql> insert into DemoTable values('John'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable values('Carol'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable values('Johnny'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable values('Robert'); Query OK, 1 row affected (0.20 sec) mysql> insert into DemoTable values('Chris'); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable values('Ramit'); Query OK, 1 row affected (0.18 sec)
Following is the query to display records from the table using select command:
mysql> select *from DemoTable;
This will produce the following output:
+------------------+ | StudentFirstName | +------------------+ | John | | Carol | | Johnny | | Robert | | Chris | | Ramit | +------------------+ 6 rows in set (0.00 sec)
Following is the query to match the first character with LIKE: i.e. all students with first name beginning from character C:
mysql> select *from DemoTable where StudentFirstName LIKE 'C%';
This will produce the following output:
+------------------+ | StudentFirstName | +------------------+ | Carol | | Chris | +------------------+ 2 rows in set (0.00 sec)
- Related Questions & Answers
- Select particular type of columns beginning with a certain letter and concatenate the names
- Find the records with % character in a LIKE query with MySQL
- Display specific table names with MySQL LIKE Operator
- How can I check the character set of all the tables along with column names in a particular MySQL database?
- In MySQL, how can we get the number code of a particular character?
- Get field value and convert a particular character from it to uppercase with MySQL
- Get the number of rows in a particular table with MySQL
- Get table names using SELECT statement in MySQL?
- MySQL query to select all fields beginning with a given number with next character a letter?
- MySQL ORDER BY CASE to display special character in the beginning
- Find all the names beginning with the letter 'a' or ‘b’ or ‘c’ using MySQL query?
- How to replace a particular character in a MySQL column?
- Finding only strings beginning with a number using MySQL Regex?
- How to match beginning of a particular string/line using Java RegEx
- How to get the screenshot of a particular section of the page like the logo of a website in Selenium with python?
Advertisements