Hello I have a postgresql question about searching on zip codes. Basicly, if I do a:
select * from my_table where zip_ = '90210';
I am returned 0 rows. I know for a fact that there is thousands of rows with that zip code. The table itself is over a million rows.
Column | Type | Modifiers
---------------------+-------------------+-----------------------------------------------------
...
zip_ | character varying |
Here is my table and I am not able to search effectively on zip_ column. The table does return a search if I use the like keyword along with % char, but that is not what I need.
my questions are:
- why when i search on zip_ lets say '90210' it comes back with 0 rows when I know there is thousands of records with the zip code of '90210'?
- if i change the type to int would that make a difference?
- do i need an index on the zip_ column?
where zip_ LIKE '%90210%'
return rows?select * from my_table where trim(zip_) = '90210';
. Does that give you any rows? (And don't change the type toint
at least if you want international addresses. Have a look at the British post code system. They have letters in them as well.)