我有两张这样的桌子,
表格1
Id Locations
-- ---------
1 India, Australia
2 US , UK
表2
Table2Id Location
-------- --------
101 Italy
102 UK
103 Hungary
104 India
我需要在条件下内连接这两个表,如果表 2Locations
中包含表 1 中Location
的字段。结果会像
Id Table2Id Location Locations
-- -------- -------- ---------
1 104 India India, Australia
2 102 UK US , UK
我尝试了类似的东西
Select t1.id,
t2.Table2Id,
t1.Locations,
t2.Location
From Table1 t1
Inner join Table2 t2 On CONTAINS(t1.Locations, t2.Location)
但是第二个参数contains
应该是一个字符串。它不允许在那里给出列名。
我不能在查询中使用temptable
或。variable
因为此查询需要在一个名为的电子邮件活动工具上运行,该工具ExactTarget
不支持temptable
和variables
。
任何帮助将不胜感激。谢谢你。