我有两个表。他们都包含(荷兰)邮政编码。 那些格式为9999AA并存储为varchar(6)。 左表中的代码是完全比较TSQL中不均匀长度的字符串
John Smith 1234AB
Drew BarryMore 3456HR
Ted Bundy 3456TX
Henrov 8995RE
My mother 8995XX
在右表中的代码可以是不完整的
1234AB Normal neigbourhood
3456 Bad neighbourhood
8995R Very good neighbourhood
我需要加入对postalcodes这些表。在这个例子中,输出必须是
John Smith Normal neighbourhood
Drew BarryMore Bad neighbourhood
Ted Bundy Bad neighbourhood
Henrov Very good neighbourhood
My mother -unknown-
所以我要加入基于邮政编码在权表长度的两个表。
有关如何做到这一点的任何建议?我只能拿出在ON语句的情况,而且这是没有那么聪明;)
妳如此吧,我编辑过。抱歉。似乎你比我更了解这个问题:) – Henrov