从另一个 MS SQL 的文本字符串中的一个表中查找单词



尝试使用" SQl like"函数从另一个表中的一个表中查找关键字但肯定完全错了

SELECT  
[table1].[id],
[table1].[name],
[table1].[place],
[table2].[key_words]
FROM [table1], [table2]
where [name] like "%" & [key_words] & "%"

在 MS Access 中,我做到了:

select 
[table1].[id],
[table1].[name],
[table1].[place],
[table2].[key_words]
from [table1], [table2]
where [table1].[name] like "*"& [table2].[key_words] &"*";

请指出正确的方向

您可以使用 concat

SELECT  
[table1].[id],
[table1].[name],
[table1].[place],
[table2].[key_words]
FROM [table1], [table2]  
where [name] like concat('%',[key_words],'%')

或者使用 sql 服务器连接 + 符号

    where [name] like '%' + [key_words] +'%'

最新更新