sql - 仅从 sql 中的地址获取邮政编码
问题描述
从 ODLN 中选择地址
这是我的结果:
15 Changi North Way Level 2 SSG WH Singapore 498770 (8:30am ~ 5pm; Avoid 11:30am ~ 1:30pm, send before 4pm) 15 Changi North Way Level 2 SSG WH Singapore 498770 (8:30am ~ 5pm; Avoid 11:30am ~ 1:30pm, send before 4pm) 15 Changi North Way Level 2 SSG WH Singapore 498770 (8:30am ~ 5pm; Avoid 11:30am ~ 1:30pm, send before 4pm) 200 Victoria Street #03-09 Bugis Junction Singapore 188021 Singapore 348 Jalan Boon Lay (Lunch: 12pm ~ 1pm) Singapore 619529 46 Penjuru Lane, Level 4 (Office), C&P Hub 3 Singapore 609206 (Avoid Lunch Time: 11.30am to 1pm, deliver before 4pm) 46 Penjuru Lane, Level 4 (Office), C&P Hub 3 Singapore 609206 (Avoid Lunch Time: 11.30am to 1pm, deliver before 4pm)
我需要我的结果:
498770
498770
498770
188021
619529
609206
609206
解决方案
如果我们假设 6 位邮政编码总是出现在 text 之后Singapore
,那么我们可以在这里使用基本字符串函数:
SELECT SUBSTRING(address, CHARINDEX('Singapore', address) + 10, 6) AS zip
FROM yourTable;
演示
推荐阅读
- php - php - How can I miss out parameters when calling a function?
- vba - VBA:组织非矩形范围(编辑)
- ikvm - GlyphVector.getoutline() 永远不会返回
- html - 使用 Python-Flask 使用 postgresql 数据库中的数据填充 html 下拉列表
- typescript - 在 Typescript 中,可以使用泛型添加属性键吗?
- api - 浮动日期之间如何查询?
- php - 为输入发送 cookie 并发送到 mysql
- phoenix-framework - Phoenix 1.4.0-dev 生成的通道测试失败并出现编译错误
- xml - 使用 xslt 从 xml 数据创建数组数组作为 csv 中的一个字段时,添加逗号作为分隔符
- android - 保持相互呼叫服务/广播