0

I have been searching endlessly for the answer to this problem I have been having:

Our team uses a query that returns a dataset with 13 columns. We want to narrow down the results by returning only rows where any string value in column "Actual Collection" is in the adjacent column "PrvPrComments". Additionally we want to do the same thing for column "Actual Manufacturer" and "PrvPrComments". If a string value in either Actual collection or Actual manufacturer exsists in PrvPrComments then we want to return that row and if it does not then exclude it.

The tricky part is that PrvPrComments is a column that has long text strings in them and so the query needs to parse through to find and match the string. They also need to be exact matches so "Pillow Perfect" and "pillow" would not be the same thing.

Here is an example posted below. I would want to return rows that contains "cowboy" and "chandelier" because there is a match but not the others:

Example of data

My initial guess would be to write a query that uses Full Text Index and/or contains. Any help would be greatly appreciated and I apologize for not having a foundation code to post here, I'm fairly new to this and am having trouble with where to start.

Thank you

brisenburg
  • 11
  • 3

2 Answers2

0
where '%' + actualCollection + '%' like PrvPrComments
paparazzo
  • 44,497
  • 23
  • 105
  • 176
0

If data is not that much you can use (like expression) to return the data,

WHERE PrvPrComments LIKE '%' + actualCollection + '%'

But if data is huge and full-text search will not be that much useful, you might have another column as a flag and populate the same at INSERTION time, (when the actualCollection is LIKE PrvPrComments then set the flag as 1 ). later you need to query against rows having flag as 1

Milad Shahbazi
  • 144
  • 1
  • 2
  • 7