问题
I have a full-text indexed table and a column that is full-text indexed which contains a list of ids and some other information.
Example:
SearchInformation
100, 101, 102, 103, 104, Mike
200, 201, 202, 203, 204, John
And my full-text query (a simplified version) is:
SELECT searchInformation
FROM Table T1
INNER JOIN CONTAINSTABLE(SearchTable, SearchInformation, '"100" OR "110" OR "Mick"') k
ON T1.ID = k.[key]
Now, this query identifies the correct row due to the "100" value being matched, but is there any way to show / select which value has been matched from my search conditions?
In this case, I also want to select the value of 100 from my query. I have looked into the Full-text documentation and I'm not sure if this is possible or if it is with maybe some additional changes in table and query design.
So, I'm looking for a result set similar to:
SearchInformation matchFound
100, 101, 102, 103, 104, Mike 100
I currently have an approach where each ID number is associated with Mike or John in a single row, like below, so then, after the match I can directly take the matched value from the ID column.
SearchInformation ID
100, Mike 100
101, Mike 101
102, Mike 102
103, Mike 103
200, John 200
201, John 201
But I would like to change this to use the previously mentioned design, if possible. I know that the previous approach is terribly non-relational, but I'm curious if it's possible.
来源:https://stackoverflow.com/questions/40484312/fulltext-show-the-matching-word-in-a-multi-word-search-condition-with-or