netraider
netraider

Reputation: 257

Length (column) greater than but spaces after the characters

I have this query to show all records where column is greater than 4 characters, however, the data contains spaces after the characters for example '1234 ' .

How could I modify the below query to ignore the spaces after the characters? Querying an Oracle database.

Many thanks.

select * 
from tablename
where length(field1) > 4

Upvotes: 0

Views: 147

Answers (1)

ntalbs
ntalbs

Reputation: 29458

You can use rtrim function to remove the trailing spaces.

select * 
from tablename 
where length(rtrim(field1)) > 4

Perhaps you want to check ltrim, trim functions, too.

Upvotes: 2

Related Questions