0

I have data like this

Country_name   | zipcode_from  |  zipcode_to
United Kingdom     JE1 OAA         JE4 9ZZ
United Kingdom     GY1 1AA         GY9 3ZZ
Spain              52001           52080

Now, I want to get row that have zipcode from range zipcode_from to zipcode_to. Example: if the zipcode is 52005, so the result is:

Spain              52001           52080

If the zipcode is JE1 9AA, the result is

United Kingdom     JE1 OAA         JE4 9ZZ

I use sql in mySql.

4

1 回答 1

0
SELECT * FROM ZipCodes WHERE zipcode_from <= '52005' AND zipcode_to >= '52005'

但它将使用标准字符串比较来执行。

于 2013-03-05T07:49:43.080 回答