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

  • SEARCH
  • Home
  • 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 6631083
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T22:29:51+00:00 2026-05-25T22:29:51+00:00

How can I update a table and create column with the id numbers for

  • 0

How can I update a table and create column with the id numbers for each entry in that ID column?

The table currently looks like:

    city    
-------------
  New York
  Los Angeles
  London
  Belgrade

I need the column in this table that would have the ID number of each city which would be ordered by column city ASC.

Something like:

 id   |   city
----------------
  1   | Belgrade
  2   | London
  3   | Los Angeles
  4   | New York

Can I do this using mysql query or I need to do that using PHP and Mysql?

  • 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-05-25T22:29:51+00:00Added an answer on May 25, 2026 at 10:29 pm
    ALTER TABLE table_name
    ADD column_name column-definition;
    

    so in your case its

     ALTER TABLE cities
     ADD id int auto-increment;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table with a row that looks like this: ( 20091231 48498429,
how can i write the query, to update the table videos , and set
If I have a trigger before the update on a table, how can I
I use this code to update data in database table. Can reuse same code
Merge can performs insert, update, or delete operations on a target table based on
In SQL Profiler you can see that very simple updates to a table by
I know I can update a single record like this - but then how
I see that EF can update a model based on an existing database schema.
How can I efficiently create a unique index on two fields in a table
I have a table of values like this: CREATE TABLE ( Name1 VARCHAR (50),

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.