Results 1 to 8 of 8
  1. #1
    frmorris
    Guest

    Creating a special query

    How would I be able to get my user to pull of all cities in a state. For example, if I wanted to put every city for every state in my database, what do I need to do to be able to pull up all cities in one state.

  2. #2
    New Lounger
    Join Date
    Jan 2001
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Creating a special query

    It could be as simple as a parameter query that asks for a state, if I understand your question.

  3. #3
    frmorris
    Guest

    Re: Creating a special query

    How would I set up my tables for this? Do I created one table with all the states and under each state I put their cities? Or would I create 50 separate tables?

  4. #4
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Creating a special query

    You need 2 tables:

    tblState has one record for each state. You could include fields for the state abbreviation and the spelled out state name.

    tblCity has one record for each city in a given state. That record would have a field for the city name, a field for the StateID (the primary key from the state table) for that City, and anything else you wanted to store about that city.
    Charlotte

  5. #5
    2 Star Lounger
    Join Date
    Jan 2001
    Location
    Indiana, USA
    Posts
    107
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Creating a special query

    Charlotte, in the tblCity, you wouldn't want a primary key field, would you? Just courious.

    frmorris, did Charlotte's recommendation help?

  6. #6
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Creating a special query

    Yes, you would. I didn't include every field because I was trying to explain the relationship. The Primary Key for the state table would be a foreign key in the City table. But each city/state combination should have its own unique key, especially since city names are not unique.
    Charlotte

  7. #7
    frmorris
    Guest

    Re: Creating a special query

    Thank you very much Charlotte. Your suggestion was a huge help. Everything is running smoothly.

  8. #8
    frmorris
    Guest

    Re: Creating a special query

    Yes. Charlotte answer was a huge help. I have everything running smoothly now.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •