Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Duplicate rows with multiple 'like' wildcard

$
0
0

Hi

I have a product table with a title field; example title values could be 'Microsoft Mouse', 'Microsoft Keyboard' or 'Logitech Keyboard'.

I want to use a select statement to identify products using 1 or more keywords, e.g. 'Microsoft' or 'Microsoft' and 'Keyboard', and return the products in descending order, based on the number of keywords matched in the title field.

For the example titles above, if I was to select using the keywords 'Microsoft' and 'Keyboard', I either want the select statement to return the product row twice, or a single product row with a match count, indicating the number of keywords matched, similar to below:

Title, Match Count

'Microsoft Keyboard',2
'Logitech Keyboard',1
'Microsoft Mouse', 1

I have tried various methods, with no success. Any help would be much appreciated.

Thanks.



Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>