May 30, 2007 at 11:40 am
Hi I am trying to use a query to find values in a specified field which have spaces. I am sure there is a much easier way to do this than I am attempting. Here is the code I am using presently.
MyField like '%_ [A-Z,_,0-9]%'
This works on most items but I want to include all values i.e. -,@,# etc. The wild card % alone does not work for my purposes as it will return values with nothing trailing a blank which I dont want. I want the query to return values like Fred Johnson, as opposed to Fred. Using -- MyField like '% %' will return both values presented before.
I hope this is not too confusing as a question?
Thanks to anyone who can help.
May 30, 2007 at 11:53 am
Not sure about what system (or settings) you have but:
select *
from
(select 'Fred Johnson' mycol
union all select 'Fred') data
where mycol LIKE '% %'
Returns *only* 'Fred Johnson' to me
* Noel
May 30, 2007 at 12:05 pm
You may have problems with the trailing spaces if your MyField is CHAR datatype not VARCHAR. In this case try using RTRIM(MyField) LIKE '% %'.
This should help.
---------------------------------------------
[font="Verdana"]Nothing is impossible.
It is just a matter of time and money.[/font]
May 30, 2007 at 12:41 pm
Thanks very much I knew there had to be a simpler way.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply