OldWest Posted November 17, 2010 Share Posted November 17, 2010 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? Quote Link to comment https://forums.phpfreaks.com/topic/219017-have-no-field-for-one-table-but-want-auto_increment-to-apply-to-insert/ Share on other sites More sharing options...
fenway Posted November 18, 2010 Share Posted November 18, 2010 I'm sorry -- sys_city ID field *is* auto-increment? If so, you're done -- just leave out the ID fields from both sides, and you'll get what you want. Quote Link to comment https://forums.phpfreaks.com/topic/219017-have-no-field-for-one-table-but-want-auto_increment-to-apply-to-insert/#findComment-1136211 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.