如何匹配从左到右的参考编号
使用SQL Server 2008
表1
参考值1
ABC123456
表2
定2
EFABC123456
ACDERERERE
ABC12345693843
我们想要将reference1与reference2表格从左到右进行比较
预期行为
表2
Reference2
EFABC123456 - Not match
ACDERERERE - Not match
ABC12345693843 - Match (its matching the complete reference from left to right with reference1 )
如何查询逻辑
尝试查询
Left(@pi_ref, Len(table1.refno)) = table1.refno then RTRIM(LTRIM(table1.refno))
此查询适用于完整的参考编号,而不是从左到右
请协助
答案 0 :(得分:1)
table2.refno like table1.refno + '%'