
- Learn MySQL
- MySQL - Home
- MySQL - Introduction
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Connection
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Data Types
- MySQL - Create Tables
- MySQL - Drop Tables
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Where Clause
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Like Clause
- MySQL - Sorting Results
- MySQL - Using Join
- MySQL - NULL Values
- MySQL - Regexps
- MySQL - Transactions
- MySQL - Alter Command
- MySQL - Indexes
- MySQL - Temporary Tables
- MySQL - Clone Tables
- MySQL - Database Info
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - Database Export
- MySQL - Database Import
Find records with a specific last digit in column with MySQL
For this, use the RIGHT() method to fetch records with a specific last digit. Let us first create a table −
mysql> create table DemoTable823(Value varchar(100)); Query OK, 0 rows affected (0.54 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable823 values('9847826'); Query OK, 1 row affected (0.52 sec) mysql> insert into DemoTable823 values('84747464'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable823 values('9899889883'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable823 values('123456'); Query OK, 1 row affected (0.10 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable823;
This will produce the following output −
+------------+ | Value | +------------+ | 9847826 | | 84747464 | | 9899889883 | | 123456 | +------------+ 4 rows in set (0.00 sec)
Following is the query to find records with a specific last digit −
mysql> select *from DemoTable823 where right(Value,1)='6';
This will produce the following output −
+---------+ | Value | +---------+ | 9847826 | | 123456 | +---------+ 2 rows in set (0.00 sec)
- Related Articles
- Find specific records from a column with comma separated values in MySQL
- Find records with double quotes in a MySQL column?
- How to find tables with a specific column name in MySQL?
- MySQL query to select everything to left of last space in a column with name records
- How to find last date from records with date values in MySQL?
- Order a column in MySQL with IP Address records?
- Find rows where column value ends with a specific substring in MySQL?
- Find out the records of students with more than a specific score in MySQL?
- How to compare the first date and the last date from a MySQL column with date records?
- How to select records that begin with a specific value in MySQL?
- MySQL query to select all the records only from a specific column of a table with multiple columns
- Display distinct dates in MySQL from a column with date records
- MySQL query to count rows with a specific column?
- Find MongoDB records with Price less than a specific value
- Find the records with % character in a LIKE query with MySQL

Advertisements