navigation
a webmaster learning community
     Home    Register     Search      Help      Login    
Sponsors

Shopping Cart Software
Ecommerce software integrated into Frontpage, Dreamweaver and Golive templates. No monthly fees and available in ASP and PHP versions.

Website Templates
We also have a wide selection of Dreamweaver, Expression Web and Frontpage templates as well as webmaster tools and CSS layouts.

Frontpage website templates
Creative Website Templates for FrontPage, Dreamweaver, Flash, SwishMax

Search Forums
 

Advanced search
Recent Posts

 Todays Posts
 Most Active posts
 Posts since last visit
 My Recent Posts
 Mark posts read

 

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
Users viewing this topic: none
Printable Version 

All Forums >> Web Development >> ASP and Database >> Zip code problem...only want 1st 5 #'s, not 4 digit extension
Page: [1]
 
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.

(in reply to jonance)
Page:   [1]

All Forums >> Web Development >> ASP and Database >> Zip code problem...only want 1st 5 #'s, not 4 digit extension
Page: [1]
Jump to: 1





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