- 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 all except the first character in a string in MySQL?
To select all except the first character in a string, you can use SUBSTR() method. Let us first create a table −
mysql> create table DemoTable ( FirstName varchar(20) ); Query OK, 0 rows affected (0.63 sec)
Insert records in the table using insert command −
mysql> insert into DemoTable values('Larry'); Query OK, 1 row affected (0.24 sec) mysql> insert into DemoTable values('Carol'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable values('Robert'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable values('David'); Query OK, 1 row affected (0.14 sec)
Display records from the table using select command −
mysql> select *from DemoTable;
This will produce the following output −
+-----------+ | FirstName | +-----------+ | Larry | | Carol | | Robert | | David | +-----------+ 4 rows in set (0.00 sec)
Here is the query to select all except the first character in a string −
mysql> select substr(FirstName,2) from DemoTable;
This will produce the following output −
+---------------------+ | substr(FirstName,2) | +---------------------+ | arry | | arol | | obert | | avid | +---------------------+ 4 rows in set (0.00 sec)
- Related Articles
- Remove all except the first character of a string in MySQL?
- Select all rows except from today in MySQL?
- MySQL query to select rows except first row in descending order?
- How to select all rows from a table except the last one in MySQL?
- How to cut only the first character in MySQL string?
- How to select all the records except a row with certain id from a MySQL table?
- How to select all columns except one in a Pandas DataFrame?
- First Unique Character in a String in Python
- Display all records except one in MySQL
- Select first word in a MySQL query?
- How to select all the characters after the first 20 characters from a column in MySQL?
- Find the first repeated character in a string using C++.
- Find sum by removing first character from a string followed by numbers in MySQL?
- Delete all rows except only a specific row in MySQL?
- Python program to replace all Characters of a List except the given character

Advertisements