[thelist] Zip Code mysql db

Russell Griechen russgri at bellsouth.net
Sun Apr 14 02:31:01 CDT 2002


I need to search for the nearest entity in range of 100?? miles.
I have a mysqldump...city table does not have a zip_code field or
zip_code_id
I would prefer to enter in zip_code either/or by memory or by data
input...maybe a zip+4 or foreign. In some tables (city for instance)I
would want to use zip_code_id and others I would use zip_code and use
info supplied by others or entered by others.
is there an option to use:

CREATE TABLE zip_code (
   zip_code varchar (15)
PRIMARY KEY (zip_code)
and would this serve as lookup table?
Any other comments appreciated
I realize I would have to alter the city table shown below.
#
# Table structure for table 'city, country, state'
#
CREATE TABLE city (
   city_id mediumint(9) DEFAULT '0' NOT NULL auto_increment,
   name varchar(75) NOT NULL,
   latitude float(7,5) DEFAULT '0.00000' NOT NULL,
   longitude float(7,5) DEFAULT '0.00000' NOT NULL,
   state_id tinyint(4) DEFAULT '0' NOT NULL,
   PRIMARY KEY (city_id),
   KEY name (name),
   KEY latitude (latitude),
   KEY longitude (longitude),
   KEY state_id (state_id)

CREATE TABLE state (
   state_id tinyint(4) DEFAULT '0' NOT NULL auto_increment,
   abbrev char(2) NOT NULL,
   name varchar(30) NOT NULL,
   country_id char(2) NOT NULL,
   PRIMARY KEY (state_id),
   KEY country_id (country_id),
   KEY name (name),
   KEY abbrev (abbrev)CREATE TABLE country (
   country_id char(2) NOT NULL,
   name varchar(50) NOT NULL,
   PRIMARY KEY (country_id),
   KEY name (name)

Russell Griechen




More information about the thelist mailing list