
- 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
MySQL query to remove first digit?
For this, use SUBSTR(). Following is the syntax −
update yourTableName set yourColumnName=substr(yourColumnName,2);
Let us first create a table −
mysql> create table DemoTable607 (Value varchar(100)); Query OK, 0 rows affected (0.69 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable607 values('83967364'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable607 values('10939432'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable607 values('932111'); Query OK, 1 row affected (0.16 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable607;
This will produce the following output −
+----------+ | Value | +----------+ | 83967364 | | 10939432 | | 932111 | +----------+ 3 rows in set (0.00 sec)
Here is the MySQL query to remove first digit −
mysql> update DemoTable607 set Value=substr(Value,2); Query OK, 3 rows affected (0.14 sec) Rows matched: 3 Changed: 3 Warnings: 0
Let us check the table once again −
mysql> select *from DemoTable607;
This will produce the following output −
+---------+ | Value | +---------+ | 3967364 | | 0939432 | | 32111 | +---------+ 3 rows in set (0.00 sec)
- Related Articles
- MySQL query to convert a single digit number to two-digit
- MySQL update query to remove spaces?
- MySQL query to remove trailing spaces
- How to remove only the first word from columns values with a MySQL query?
- MySQL update query to remove spaces between letters?
- MySQL query to remove text between square brackets?
- MySQL query to format numbers which has space between digit?
- MySQL query to remove Null Records in a column?
- MySQL query to remove special characters from column values?
- MySQL query to extract first word from a field?
- Select first word in a MySQL query?
- How to write a MySQL query to select first 10 records?
- MySQL Query to remove all characters after last comma in string?
- MySQL query to select rows except first row in descending order?
- Remove first two characters of all fields in MySQL?

Advertisements