简体   繁体   中英

Removing whitespaces from records not working correctly in SQL

I have a dataset that was cleansed thanks to another user of Stackoverflow. I have one problem though:

I have a series of telephone numbers:

000 6556 064666
566 2123 654566
433 4525 454252

I need to get rid of the white spaces to format as follows:

0006556064666
5662123654566
4334525454252

I've tried using REPLACE, but something has gone wrong because I expect the returned query to return 100,580,145 records after matching the non-white spaced rows with another table, but I am getting less than 40,000.

How can I efficiently remove these white spaces?

Use REPLACE() function: Try this:

SELECT REPLACE(column1, ' ', '') AS col1 
FROM tableA; 

You can update the data as well:

UPDATE tableA 
SET column1 = REPLACE(column1, ' ', '');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM