Welcome to WebmasterWorld Guest from

Forum Moderators: open

Message Too Old, No Replies

Having Issues With First Dynamic Site

Trying to access infro two tables

12:18 pm on Jan 21, 2006 (gmt 0)

Junior Member

10+ Year Member

joined:Apr 5, 2003
votes: 0

Ok, what I have is 1 DB that contains 2 tables

Table #1 = geocoding
Table #2 = stores

What I basically am trying to do is have a search box on a page that looks up a zipcode (zipid) from the geocoding table. It then finds the 4 closest stores (store1,store2,store3,store4 in the geocoding table)

Then I want to display the info from the stores table that corresponds to the store1,store2,store3,store4 fields from that specific zipid (Store name, address,city,state,zip,phone,fax,email,website,owners name)

Im really lost as to how to write that sql statement?

In the Geocode table I have these fields:
id, ZipdId, Store1, Store2, Store3, Store4 (and a couple more that we dont need to use)

In the stores table I have these fields:
storeNum (this is the number that would appear in the store1-4 fields in the geocode table), storename,address1, address2, city, state, zip, country, phone, fax, email, website, owner

Any help would be greatly appreciated. Im using an access db, with asp btw.

11:43 pm on Jan 21, 2006 (gmt 0)

New User

10+ Year Member

joined:Jan 21, 2006
votes: 0

SELECT ..., stores.storename, stores.address1, ... FROM geocoding, stores WHERE geocoding.ZipId=#*$! AND (geocoding.Store1=stores.storeNum OR geocoding.Store2=stores.storeNum OR geocoding.Store3=stores.storeNum OR geocoding.Store4=stores.storeNum)

As for my mind, the newbie in SQl it has to be so.

12:28 pm on Jan 22, 2006 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:June 13, 2002
votes: 0

Your tables seem to be set up wrong, How does the zipID in geocoding relate to the zipCode in Stores?

If its the same thing then you could maybe use a query like this;

select * from stores
where storenum in (select store1,store2,store3,store4 from geocoding where zipId=@myZip)

IMO the way to do this feature professionally is to store the longtitue and lattitude values for your zip codes and write code to work out the distance between two zip codes.


Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members