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
 General SQL Server Forums
 New to SQL Server Programming
 Newbie question - viewing all occurances

Author  Topic 

english_twit
Starting Member

3 Posts

Posted - 2005-08-12 : 07:53:51
Hi all

I have two tables.
Keywords Table
Keywords |SIC Code |Thomson Code |
School |8010 | 44444 |
Turnip |4444 | 555555 |
Break |99999 | 33333 |

Company File
Vendor | Add1 | Add2 | etc etc
Primary School | High Street | etc
Turnip Farm | Countryside | etc
Breakdown Serv | Industrial |
Turnip School Break | Kidding! |

What I need is a query that will match all the keywords in the keywords table in the Vendor field of the Company file table. i.e
Vendor | Keyword(s)9 |
Primary SChool | School |
Turnip Farm | Turnip
Turnip School Break | SChool,Turnip,Break |

I can get the query reporting singluarlary, but not the last option.

Apologies if this looks basic... but I am struggling!

Regards

Dom






Er yes. That worked. What?

<edit> Moved to appropriate forume </edit>

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-08-12 : 08:05:53
Try this

Select V.vendorCode from vendor V , Keyword K where vendorcode like '%'+K.keycode+'%'


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

english_twit
Starting Member

3 Posts

Posted - 2005-08-12 : 09:09:57
Madhivanan

this is great but I don't see the keywords that match. SO for instance this is the result that I get

Vendor Name Postcode Keyword
ABBEYFIELDS DAY NURSERY#002 ME13 8DL Nursery
ABBEYFIELDS DAY NURSERY#002 ME13 8DL Day

But the result I want to see is

Vendor Name Postcode Keyword
ABBEYFIELDS DAY NURSERY#002 ME13 8DL Nursery,Day

because I am matching on DAY and NURSERY

Once again, apologies if this seems simple, but I'm not really a techie!

Regards

Dom


Er yes. That worked. What?
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-08-12 : 09:11:44
Refer this
http://sqljunkies.com/WebLog/amachanic/archive/2004/11/10/5065.aspx?Pending=true

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

english_twit
Starting Member

3 Posts

Posted - 2005-08-12 : 10:19:13
Madhivanan

Excellent - it'll take me a while to figuer this out for me, but it's what i need. I'll do it when I return from vaction in two weeks (what a get out)

Many thanks

Dom

Er yes. That worked. What?
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-08-12 : 10:26:07
>>I'll do it when I return from vaction in two weeks (what a get out)

well

Have a nice vacation


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -