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.
| Author |
Topic |
|
benildusmuerling
Yak Posting Veteran
81 Posts |
Posted - 2012-08-23 : 03:22:11
|
| Good day to my excellient members, I would like to ask a question on how would I use the contains keyword.My scenario, I've got at the moment is to order the records by the most number of keywords.for example, if someone hit 'Time Travellers Wife' in the search bar, and the table in that column which is searching for, if it is having records as 1) Time2) Time Travellers3) Time Travellers Wifeit should return in the order of below.1) Time Travellers Wife2) Time Travellers3) TimePS : order in the most number of keywords, and then one after the otherThanks,AB |
|
|
nigelrivett
Master Smack Fu Yak Hacker
3385 Posts |
Posted - 2012-08-23 : 05:40:22
|
| split the words up into a table variable or cte thenselect t.titlefrom tbl tjoin @keyword kon ' ' + t.title + ' ' like '% ' + k.keyword + ' %'group by t.titleorder by count(*) desc==========================================Cursors are useful if you don't know sql.SSIS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
|
|
|