
- 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 format numbers which has space between digit?
Let us first create a table −
mysql> create table DemoTable1546 -> ( -> Number varchar(20) -> ); Query OK, 0 rows affected (0.99 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable1546 values('145 78 90'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable1546 values('89 789 564 903'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable1546 values('1345 7894 866 653534'); Query OK, 1 row affected (0.12 sec)
Display all records from the table using select statement −
mysql> select * from DemoTable1546;
This will produce the following output −
+----------------------+ | Number | +----------------------+ | 145 78 90 | | 89 789 564 903 | | 1345 7894 866 653534 | +----------------------+ 3 rows in set (0.00 sec)
Following is the query to format numbers by replacing space between numbers −
mysql> update DemoTable1546 set Number=replace(Number,' ',''); Query OK, 3 rows affected (0.13 sec) Rows matched: 3 Changed: 3 Warnings: 0
Let us check the table records once again −
mysql> select * from DemoTable1546;
This will produce the following output −
+-------------------+ | Number | +-------------------+ | 1457890 | | 89789564903 | | 13457894866653534 | +-------------------+ 3 rows in set (0.00 sec)
- Related Articles
- MySQL query to remove first digit?
- MySQL query to convert a single digit number to two-digit
- How to convert Python date format to 10-digit date format for mysql?
- MySQL query to convert height format to centimeters?
- How to convert US date format to MySQL format in INSERT query?
- MySQL query to extract time in a format without seconds
- MySQL date format DD/MM/YYYY select query?
- MySQL select to convert numbers to millions and billions format?
- Format date in MySQL SELECT * query uisng FORMATDATE() method?
- Space format specifiers in Java
- How to use constant in ABAP program which has trailing space?
- MySQL query to convert YYYY-MM-DD to DD Month, YYYY date format
- Get date format DD/MM/YYYY with MySQL Select Query?
- Remove space between two words in MySQL?
- MySQL query to remove numbers after hyphen in a VARCHAR string with numbers

Advertisements