- 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
MySQL query to select column values ending with certain character/number?
Let us first create a table −
mysql> create table DemoTable ( Number int ); Query OK, 0 rows affected (0.80 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable values(189); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable values(178); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable values(876); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable values(784); Query OK, 1 row affected (0.23 sec) mysql> insert into DemoTable values(988); Query OK, 1 row affected (0.23 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
This will produce the following output −
+--------+ | Number | +--------+ | 189 | | 178 | | 876 | | 784 | | 988 | +--------+ 5 rows in set (0.00 sec)
Following is the query to select column values ending with a specific character/number. Here, we are focusing on values ending with number 8 −
mysql> select *from DemoTable where Number LIKE '%8';
This will produce the following output −
+--------+ | Number | +--------+ | 178 | | 988 | +--------+ 2 rows in set (0.00 sec)
- Related Articles
- Add a character in the end to column values with MySQL SELECT?
- MySQL query to select all fields beginning with a given number with next character a letter?
- MySQL query to sort by certain last string character?
- MySQL query to separate and select string values (with hyphen) from one column to different columns
- MySQL query to select a record with two exact values?
- MySQL query to get the character length for all the values in a column?
- MySQL query to select the nth highest value in a column by skipping values
- MySQL query to select three highest values and sort alphabetically on the basis of corresponding column with name
- MySQL query to display only the column values with corresponding column having whitespace
- Sort character values from a column mixed with character and numbers in MySQL?
- MySQL query to count number of duplicate values in a table column
- MySQL query to retrieve only the column values with special characters?
- MySQL randomly select 2 values from column values?
- Select the table name as a column in a UNION select query with MySQL?
- MySQL query to display record with maximum count values in a group with other column values?

Advertisements