Reputation: 35
I have a DB with more than 1,000,000 entries in it, some of them contain space char at the start/end of the value.
I have tried the following queries and it works but i would have to go through 1,000,000 records because all id's are unique
select * from tablename where id like '%1234%';
select * from tablename where id='1234 ';
select * from tablename where id=' 1234';
select * from tablename where id=' 1234 ';
is there a query that can be run that returns all values with space/empty char at the start/end of the value?
Appreciate your help B
Upvotes: 3
Views: 9301
Reputation: 1812
You can use a regular expression that says "one or more spaces at the start of the string OR one of more spaces at the end of the string".
select * from tablename where id ~ '^\s+|\s+$';
Each special character:
Upvotes: 8
Reputation: 35
I found the way to do this
select * from tablename where id like '% %';
Upvotes: -3