我们说我有下表" Addresses
":
+----+-------------+---------------+------------------+
| ID | CompanyName | Street | City |
+----+-------------+---------------+------------------+
| 1 | Salvador | Hollywood 123 | Paradise City |
| 2 | Zer0 | Avenue 34 | Opportunity City |
+----+-------------+---------------+------------------+
如果我进行全文搜索,请执行以下操作:
SELECT * FROM Addresses WHERE CONTAINS(*, 'Salv')
是否可以回来
答案 0 :(得分:1)
我可以建议:
SELECT
*,
CASE WHEN CONTAINS(CompanyName, 'Salv') THEN 'CompanyName'
WHEN CONTAINS(Street, 'Salv') THEN 'Street'
WHEN CONTAINS(City, 'Salv') THEN 'City'
END As ColumnName,
CASE WHEN CONTAINS(CompanyName, 'Salv') THEN CompanyName
WHEN CONTAINS(Street, 'Salv') THEN Street
WHEN CONTAINS(City, 'Salv') THEN City
END As FullText
FROM Addresses
WHERE CONTAINS(*, 'Salv')