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)
 LIKE operator

Author  Topic 

js.reddy
Yak Posting Veteran

80 Posts

Posted - 2007-07-12 : 08:35:28
Hi all

I have a temptable called #TempParts

the content of #TempParts may be

partname
---------
gandhi
nehru
indira
karuna
jaya

and here i have one more main table called bookMain


The main table bookMain may contain
bookname
---------
Mahatma Gandhi
Indira Gandhi
The story of Gandhi
Javarlal Nehru
The Last Day of Gandhi
indira
karuna nidhi
jaya lalitha

Here I want to display all rows from bookMain which are related to #TempParts


I think here we can use IN and LIKE operators. But I am not getting.


Thanks
JS.Reddy











khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-07-12 : 08:43:24
[code]SELECT *
FROM partname p INNER JOIN bookname b
ON b.bookname LIKE '%' + p.partname + '%'[/code]


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

js.reddy
Yak Posting Veteran

80 Posts

Posted - 2007-07-12 : 08:53:56
Thank you KH
quote:
Originally posted by khtan

SELECT *
FROM partname p INNER JOIN bookname b
ON b.bookname LIKE '%' + p.partname + '%'



KH
[spoiler]Time is always against us[/spoiler]



Go to Top of Page
   

- Advertisement -