2016-03-09 20 views
1

試圖找到一個表中功能 另一個使用「像SQL」一鍵字的文本字符串,但肯定做完全以錯誤查找一個表中的字的另一MS SQL

SELECT 

[table1].[id], 
[table1].[name], 
[table1].[place], 
[table2].[key_words] 

FROM [table1], [table2] 

where [name] like "%" & [key_words] & "%" 

在MS Access I`ve做到了想:

select 

[table1].[id], 
[table1].[name], 
[table1].[place], 
[table2].[key_words] 

from [table1], [table2] 

where [table1].[name] like "*"& [table2].[key_words] &"*"; 

點我朝着正確的方向請

+0

只需更換*同%且具有+ – artm

回答

2

您可以使用CONCAT

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

或者與SQL Server concating +簽名

where [name] like '%' + [key_words] +'%' 
相關問題