我有两个表格。它们都包含(荷兰)邮政编码。这些编码的格式为9999AA,存储为varchar(6)。在左侧的表格中,编码是完整的。
John Smith 1234AB
Drew BarryMore 3456HR
Ted Bundy 3456TX
Henrov 8995RE
My mother 8995XX
在右侧的表格中,代码可能不完整。
1234AB Normal neigbourhood
3456 Bad neighbourhood
8995R Very good neighbourhood
我需要根据邮政编码连接这些表。在这个例子中,输出必须是:
John Smith Normal neighbourhood
Drew BarryMore Bad neighbourhood
Ted Bundy Bad neighbourhood
Henrov Very good neighbourhood
My mother -unknown-
我的任务是将两张表格基于右边表格中的邮政编码长度连接起来。
您有什么建议吗?我只能想到在ON语句中使用CASE,但那并不太聪明 ;)