Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 retrieving string records

Author  Topic 

gmunky
Starting Member

5 Posts

Posted - 2007-03-28 : 12:27:08
I was wondering if there's an easy way to just retrieve records of strings given the first two characters and the last two characters.

if the table looks like this:
-----------
hello
hemmmlo
hemmmmjl
hennnnlo
------------

I want to be able to retrieve all strings that begins with 'he'
and ends with 'lo' which are hello,hemmmlo,and hennnnlo

I tried using select from table where string = '%lo' and string='he%'
but that doesnt work.

thanks.


khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-03-28 : 12:31:23
[code]
select *
from table
where col like 'he%lo'
[/code]


KH

Go to Top of Page
   

- Advertisement -