Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Removing spaces from a string, SQL

Tags:

sql

oracle

I'm trying to write a SQL query that will remove all spaces so that if a string only has spaces the final string is just ''.

I've tried this code but apparently it isn't working for more than one space:

regexp_replace(:P14_search_text, '( ){1,}', '')

Being :P14_search_text the string I want to modify.

Any help?

like image 447
Raúl Núñez Cuevas Avatar asked Dec 12 '12 18:12

Raúl Núñez Cuevas


People also ask

How do you handle spaces in SQL?

DML SQL query with space in a column name When we run INSERT, UPDATE, and DELETE statements, we must use a square bracket or double quotes to handle the column name with space.

How do I remove blank lines in SQL query?

To delete blank lines from a query, use the Delete blank Lines button on the query toolbar.

Does delete free the space in SQL?

After you use a DELETE statement in Microsoft SQL Server to delete data from a table, you may notice that the space that the table uses is not completely released.

What is TRIM and Ltrim in SQL?

Returns a Variant (String) containing a copy of a specified string without leading spaces (LTrim), trailing spaces (RTrim), or both leading and trailing spaces (Trim). Syntax. LTrim ( string ) RTrim ( string ) Trim( string )


1 Answers

how about:

regexp_replace(:P14_search_text, '[[:space:]]*', '');
like image 141
Julien May Avatar answered Oct 03 '22 07:10

Julien May