|
| |
Zip code problem...only want 1st 5 #'s, not 4 digit extension
View related threads:
(in this forum
| in all forums)
|
Logged in as: Guest
|
|
|
jonance
Posts: 298 From: Louisville KY USA Status: offline
|
Zip code problem...only want 1st 5 #'s, not 4 digit ext... - 1/15/2008 2:16:40
Hey all....i am trying to allow my website visitors to narrow down a database of restaurants by zip code. However, my db has the zip codes with the 4 digit extension. I need my sql which displays the zip codes to only display the distinct first 5 digits of the zips available. Here is my sql currently:
SELECT * FROM listings WHERE (sic = '581208' AND activated = 'yes') ORDER BY zip ASC
Can anyone help me do this? Thanks in advance, John
|
|
|
|
rdouglass
Posts: 9280 From: Biddeford, ME USA Status: offline
|
RE: Zip code problem...only want 1st 5 #'s, not 4 digit... - 1/15/2008 9:24:59
To use DISTINCT, I don't think you can use the * symbol but rather list each field like this and then use the LEFT function: SELECT DISTINCT Field1, Field2, Field3, LEFT(ZIPCode, 5) AS ZIPCode WHERE (sic = '581208' AND activated = 'yes') ORDER BY ZIPCode ASC Of course, change the fields to match yours. That should get you close. Hope it helps.
_____________________________
Don't take you're eye off your final destination. ASP Checkbox Function Tutorial.
|
|
New Messages |
No New Messages |
Hot Topic w/ New Messages |
Hot Topic w/o New Messages |
Locked w/ New Messages |
Locked w/o New Messages |
|
Post New Thread
Reply to Message
Post New Poll
Submit Vote
Delete My Own Post
Delete My Own Thread
Rate Posts
|
|
|