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
 Searching based on Content in a column

Author  Topic 

ashapiro75
Starting Member

3 Posts

Posted - 2008-12-30 : 15:55:54
I am fairly new to sql server 2005 and I am working on a little project.
Lets say I have a color table and an items table. I want to search through items.description for color.name and set items.color = color.name.

I understand how to do this if I am using an inner join but that's not what I want to do. An inner join is good if I have a color.code that I can match with a portion of item.partnumber. However on what I want to do, basically I need to build a table that contains the words I am looking for, loop through that table and remove them or add them to the second table based on what's in the description field.

Inner join is about as sophisticated as I am with Sql....
I was looking to use CONTAINS or CONTAINSTABLE but I have no idea what I am doing with full text searches.

Can anyone help me out on this?

AS

Jai Krishna
Constraint Violating Yak Guru

333 Posts

Posted - 2008-12-30 : 22:45:51
Please post ur table structure,table data and the expected output

Jai Krishna
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-12-31 : 03:06:11
build a table from words? where will you get words from? is it passed as a parameter?
Go to Top of Page

ashapiro75
Starting Member

3 Posts

Posted - 2008-12-31 : 08:33:41
Maybe I was a little to vague -
I get product data from a manufacturer, in that data I have a part number, a description and a weight. From those three fields I need to figure out the Part Name, The Finish and the Product Line.

I will use finish as an example -
Finish Table -
FinishID
FinishName
FinishCode
FinishVendor

Product Table
productID
PartNumber
Vendor
Finish (empty)
Description
Weight
PartName
ProductLine


I pre-populate the finish table via an .asp form... So I have all the finishes and codes in there.
Then I do an inner join by separating out the portion of the ProductTable.partNumber into the ProductTable.finish column that corresponds to the finish. Then join it on the finish code and vendor name, that's easy.

What I want to do is figure out how to compare the ProductTable.Description to the "Array" of finish names that are stored in the FinishTable. Not every product has a code in the part number that refers to it's finish so I have to do things this way on some product lines.

Select * from productTable where description like '%'+(select finishNames from finishTable)+'%'
Illustrates what I thought I might be able to do but it doesn't work against multiple returned values.


I have a PartName table as well that was generated by selecting unique part names from the original product table that I had gone through and manually pulled out.

The ProductLine table is pre-loaded from spread sheets usually but I also have forms built to manually populate it.


What I am trying to do is cross reference the contents of 1 cell with the values in a column in another table...
I thought CONTAINS or CONTAINSTABLE might be the way to do this.

Does this make more sense as to what I am trying to do???



AS
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-12-31 : 08:39:55
seems like what you need is

Select * from productTable pt
inner join finishTable ft
on pt.description like '%'+ ft.finishNames +'%'
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-12-31 : 08:50:58
quote:
Originally posted by ashapiro75

Stupid question, what does the pt reference? ft? like I said, I am new to Sql Server, hell I am new to sql. I have been working with this for about 3 months total.

AS



they are called table aliases,short names for two tables so that we dont have to repeat table name on each place.
Go to Top of Page
   

- Advertisement -