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)
 Multiple LIKE queries

Author  Topic 

Fighter of Foo
Starting Member

2 Posts

Posted - 2007-06-05 : 10:56:11
Noob question here...

I'm trying to pull IDs for all companies on a given list. Trouble is the names don't quite match up, so I'm trying to use a LIKE query.

Is there any way to do this on multiple names?

select * where company_name like 'name1%', 'name2%'...

nr
SQLTeam MVY

12543 Posts

Posted - 2007-06-05 : 11:00:33
select distinct company_name
from tbl t
join (select name = 'name1%' union select 'name2%' ...) names
on t.company_name like names.name


==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

Fighter of Foo
Starting Member

2 Posts

Posted - 2007-06-05 : 11:48:26
grazie
Go to Top of Page
   

- Advertisement -