how to search a blank space

  • Thread starter old.rhodesiascout
  • Start date
O

old.rhodesiascout

Guest
hello everyone,

I'd like to know how would i state a SELECT statement that finds me words in a column "NAME" that begin with a space and followed by a word.

e.g. ' John' , ' Peter', ' Paul'
 
O

old.Jernau

Guest
Lo

Look up the commands LTRIM and RTRIM (the syntax is different in Oracle and MS SQL Server so your mileage may vary).

e.g. in sql server

SELECT * from tableName where ltrim(rtrim(columnName)) = 'bob'

will search for records in your table where the column contains things like...

'bob'
' bob'
'bob '
' bob '

Sorted?

Ta

J
 
O

old.Jernau

Guest
Or perhaps i could read the question :)

To find things that have ONE space infront of something else, try using...

SELECT * from tableName where columnName like ' %'

might work, or perhaps...

SELECT * from tableName where mid(columnName, 1, 1) = ' ' and mid(columnName, 2, 1) is not null

the mid function will be substr if you're using Oracle.

Any good?

J
 
O

old.rhodesiascout

Guest
it worked

Yup it worked.

I tried the :

SELECT * FROM table1 WHERE name LIKE ' %'

and it gave me the results.

Thanks a lot.:D
 

Users who are viewing this thread

Similar threads

L
Replies
6
Views
566
Jonty
J
W
Replies
2
Views
904
whipped
W
M
Replies
4
Views
495
W
O
Replies
1
Views
641
old.babs
O
O
Replies
4
Views
494
old.JBX-SkyWalker
O
Top Bottom