Lovish Choudhary
Lovish Choudhary

Reputation: 167

SQL Query to return result with and without whitespace

I have a column in my Postgres database table which contains a value with some whitespaces in between. For example, a value present in the column is '123 1062 10'.

Now, I want to write an SQL query which can return the row which contains the above-mentioned value by passing in the value '123106210' in the where clause of SQL Query.

Any ideas of how can write to the SQL Query to get the desired result?

Upvotes: 0

Views: 491

Answers (1)

replace function does not work for you?

This works

select replace('123 1062 10',' ','')::bigint

so this could be your final select:

select ...
from ...
where replace(your_text_column,' ','')::bigint = 123106210

Upvotes: 2

Related Questions