Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7850721
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T18:57:18+00:00 2026-06-02T18:57:18+00:00

I currently have a database table called civic_zip_code with zip, city, state, latitude, longitude

  • 0

I currently have a database table called civic_zip_code with zip, city, state, latitude, longitude columns.

I’ve been trying to get this working for a little while now and I can’t quite figure it out. Basically, since some cities have multiple zip codes, I’m trying to create a table that will allow me to associated all zip codes with that city. Since I want to have it readily available, I would like to dump it into a table, so I’m trying to come up with a SELECT INTO statement that will do it all for me.

I currently have this:

select distinct concat(city, ', ', state) as location, city, state, group_concat(zip SEPARATOR '|') as zip_codes 
from civic_zip_code 
group by city

What I have seems close, but what I’m seeming to have a problem is that it seems to only be using distinct on the city. I’m getting only Rochester, MN in the results, where I’m sure there should at least be a Rochester, NY as well. Also, it is combining the zip codes, so although I’m only getting Rochester, MN, it is including the Rochester, NY zip codes within the zip_codes column for Rochester, MN.

Below is exactly what I’m seeing for Rochester.

location       city          state          zip_codes
-------------- ------------- -------------- -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Rochester, MN  Rochester     MN             55903|55904|55905|55906|48309|55902|55901|46975|48308|53167|48307|48306|62563|79544|42273|05767|14664|14683|14653|14660|14673|02770|03839|14694|14652|14651|14650|14649|14692|03868|15074|03866|03867|14647|14607|14606|14639|14642|14064|14601|14611|14608|14610|14602|14621|14622|14626|14603|14624|14609|14627|14604|14605|14623|14643|14619|14612|14625|14644|14613|14645|14646|14617|14618|14614|14616|14620|14615|14638|98579

I know at least the 146xx zip codes should be part of Rochester, NY rather than Rochester, MN.

Even if I take distinct out, it seems to be running into the same problem.

I tried a few other queries but none of them seemed to get what I was looking for.

Is there something I’m missing or an easy way to achieve what I’m looking for?

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T18:57:19+00:00Added an answer on June 2, 2026 at 6:57 pm

    It sound like you want to group by both city and location. Like this:

    select distinct concat(city, ', ', state) as location, city, state, group_concat(zip SEPARATOR '|') as zip_codes 
    from civic_zip_code 
    group by concat(city, ', ', state),city
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to normalize a mysql database.... I currently have a table that contains
In our inventory database (SQL Server 2008 std edition) we have a table (called
I currently have database setup like so: CREATE TABLE `article` ( `id` int(11) NOT
I currently have a MySQL table called _post and i have a column called
I currently have a database with two tables called Articles and Tags . In
I have a table called products in a MySQL database. products looks some what
I have a table called People one of the columns is an xml field
I have a database with a table called Patient. In my view I have:
I currently have the following code coming from a database table: <h1 class=widgetHeader>My Friends</h1>
I have a table called emaildata consisting of 4 columns emailaddress, domainname, data and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.