将领先的0 ne添加到ZipCode是长度小于5个邮政编码
我有一个包含邮政编码的表格,但是对于有领先0或0的Zips,它们被排除在外 - 我有
ALTER cbsa_locations CHANGE zip zip CHAR(5);
UPDATE cbsa_locations SET zip=LPAD(zip, 5, '0');
可在沙箱中更改表的工作。但这在我们的数据可视化软件中不起作用。是否有一种方法可以在查询中更新ZIP,然后将该表在同一查询中的邮政编码上加入另一个表。
前任。 Brokerage_Coverage Table具有Brokerage_code,ZIP,CBSA_LOCATIONS表具有Zip City,State,County。我想加入Zip上的那些,以获取该县的经纪人_Coverage,但CBSA_LOCATIONS ZIP FIELD缺少领先的0。
select bc.brokerage_code,
bc.zip,
cbsa.county
from brokerage_coverage bc
join cbsa_locations cbsa on cbsa.zip = bc.zip
I have a table that includes zip codes but for zips where there is a leading 0 or 0's they are excluded - I have
ALTER cbsa_locations CHANGE zip zip CHAR(5);
UPDATE cbsa_locations SET zip=LPAD(zip, 5, '0');
which works in changing the table in sandbox. But it doesn't work in our data visualization software. Is there a way to update the zip in a query and then join that table to another one on the zip code in the same query.
Ex. brokerage_coverage table has brokerage_code, zip and the cbsa_locations table has zip city, state, county. I want to join those on zip to get the county for brokerage_coverage but cbsa_locations zip field is missing the leading 0's.
select bc.brokerage_code,
bc.zip,
cbsa.county
from brokerage_coverage bc
join cbsa_locations cbsa on cbsa.zip = bc.zip
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以在连接条件下使用缺少0的列添加列:
You can pad the column with the missing 0 in the join condition: