

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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 Questions & Answers
- MySQL query to remove first digit?
- How to use constant in ABAP program which has trailing space?
- 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?
- Space format specifiers in Java
- Remove space between two words in MySQL?
- MySQL date format DD/MM/YYYY select query?
- MySQL select to convert numbers to millions and billions format?
- MySQL query to extract time in a format without seconds
- Format date in MySQL SELECT * query uisng FORMATDATE() method?
- MySQL query to return only the rows which are numeric?
- MySQL query to add dots if string has more than 10 words?
- MySQL query to check if a certain row has only two words?
Advertisements