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)
 complex select statement, is it possible

Author  Topic 

rnbguy
Constraint Violating Yak Guru

293 Posts

Posted - 2007-03-20 : 00:45:29
i have several tables refered to as table A, with sentenses in each field

and one table B with a word in each field

what i would like to do is find if ANY of table A's fields contain any word found in table B.

for example:

table A:
1 | i like sql
2 | i am sql
3 | sql team will be able to figure this out

table B:
1 | SQL
2 | soccer

the query would see if table A containt the words SQL or (not and) soccer.

LoztInSpace
Aged Yak Warrior

940 Posts

Posted - 2007-03-20 : 01:31:14
Have you looked at text indexing?
Go to Top of Page

chiragkhabaria
Master Smack Fu Yak Hacker

1907 Posts

Posted - 2007-03-20 : 04:01:31
There are 2 ways to achieve this one as suggested my LozInSpace and the Second is using join with Like operators


Select * From TableA A Inner Join TableB B
On A.Col1 Like '%' + B.Col1 + '%'


Chirag

http://chirikworld.blogspot.com/
Go to Top of Page

rnbguy
Constraint Violating Yak Guru

293 Posts

Posted - 2007-03-20 : 18:24:09
excellent work guys thanx
Go to Top of Page
   

- Advertisement -