2017-05-25 57 views
-2

我在SQL Server下表:搜索VARCHAR列

表1

id bigint 
desc nvarchar(255) 

表2

id bigint 
email nvarchar(25) 

我想創建一個查詢,在表2的電子郵件列中查找表1的desc列。

例如,以下應返回匹配:

Table 1 desc = 'This is a test of [email protected] query to return results'. 

Table 2 email = '[email protected]' 

任何幫助,將不勝感激。

+0

提示:加入...但你有沒有嘗試過的東西沒有? –

+1

[比較列與另一部分相似的列]的可能重複(https://stackoverflow.com/questions/4700550/compare-columns-where-one-is-s- similar-to-part-of-another) –

回答

0

您可能需要加入兩個表,做類似如下:

select * from #table1 t1 inner join #table2 t2 on t1.id = t2.id 
    and t1.descr like '%' + t2.email + '%'