如何查找加拿大邮政编码范围之间的记录

时间:2016-07-12 06:53:52

标签: php mysql range zipcode

我想查找两个加拿大邮政编码之间的所有记录。

我用过:

SELECT count(*) as target FROM `subscribers` WHERE (zipcode BETWEEN "A0A1A0" AND "A0A2A9" ) 

这个查询没有给我正确的输出。有人可以帮忙吗?

1 个答案:

答案 0 :(得分:0)

如果正确分配了邮政编码,您可以使用不带()

的查询
SELECT count(*) as target 
FROM `subscribers` 
WHERE  zipcode BETWEEN "A0A1A0" AND "A0A2A9" ; 

最终你不能执行修剪以删除隐形字符

SELECT count(*) as target 
FROM `subscribers` 
WHERE  trim(zipcode)  BETWEEN "A0A1A0" AND "A0A2A9" ;