- 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
How can we get some last number of characters from the data stored in a MySQL table’s column?
To get some last number of characters from the data stored in MySQL table’s column, we can use MySQL RIGHT() function. It will return the number of characters specified as it argument. We need to provide the name of the column, having the particular record from which we want to get last characters, as its first argument. To demonstrate it we are taking the example of a table named ‘examination_btech’ having the following examination details of students −
mysql> Select * from examination_btech; +-----------+----------+--------+ | RollNo | Name | Course | +-----------+----------+--------+ | 201712001 | Rahul | B.tech | | 201712002 | Raman | B.tech | | 201712003 | Sahil | B.tech | | 201712004 | Shalini | B.tech | | 201712005 | Pankaj | B.tech | | 201712006 | Mohan | B.tech | | 201712007 | Yash | B.tech | | 201712008 | digvijay | B.tech | | 201712009 | Gurdas | B.tech | | 201712010 | Preeti | B.tech | +-----------+----------+--------+ 10 rows in set (0.00 sec)
Now if we want to get the last three characters from the series of roll no then it can be done with the help of RIGHT() function as follows −
mysql> Select RIGHT(RollNo, 3) FROM examination_btech; +------------------+ | RIGHT(RollNo, 3) | +------------------+ | 001 | | 002 | | 003 | | 004 | | 005 | | 006 | | 007 | | 008 | | 009 | | 010 | +------------------+ 10 rows in set (0.00 sec)
- Related Articles
- How can we get some starting number of characters from the data stored in a MySQL table’s column?
- How can we find the index position of a string stored as a record in MySQL table’s column?
- How can I use MySQL OCTET_LENGTH() function to count the number of characters stored in a data column?
- How to alter the data type of a MySQL table’s column?
- How can we apply COALESCE() function on a MySQL table’s data value?
- How can we write MySQL stored procedure to select all the data from a table?
- How can we create a MySQL stored function that uses the dynamic data from a table?
- How to get first N characters from a MySQL column?
- Strip last two characters of a column in MySQL?
- How to TRIM x number of characters, beginning from the last in MySQL?
- How can we delete a MySQL stored function from the database?
- How can we add day/s in the date stored in a column of MySQL table?
- How can we copy data with some condition/s from existing MySQL table?
- How can we add a time interval to date stored in a column of MySQL table?
- How can we change the data type of the column in MySQL table?

Advertisements