Jump to content

Have no field for one table, but want auto_increment to apply to INSERT


Recommended Posts

I am simply adding records but locations_all does not have an id field, and I just want to auto_increment into the ID field of sys_city from the last highest record ID. Here is what I have so far:

 

INSERT INTO sys_city (ID, Mid, cityName) SELECT id, state_id, city_state FROM locations_all

 

So I would like id from locations_all be set to (int)auto_increment like:

 

INSERT INTO sys_city (ID, Mid, cityName) SELECT (int)auto_increment, state_id, city_state FROM locations_all

 

The highest ID in sys_city is 2538, and I would like all records to continue from that number in the ID...

 

I know something like this must be possible, but I cannot find a solution. Any ideas how to address this?

 

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.