Answer the question
In order to leave comments, you need to log in
How to create a table where the records match the records from the old table?
Right from the start, there is a typical users table. It had all sorts of login data, registration date and nickname.
Now it's a little overgrown with the whole beginning and you need to put other data, for example, a phone number or Last Name. They will rarely be used in practice, so I want to put them in a separate table. There will be separate data fields, but the same id (primary index). In the right places on the site through JOIN, it's easy to display.
How to synchronously insert all users into the second table so that the id's match? Is such synchronization possible?
Answer the question
In order to leave comments, you need to log in
do you need a new table? maybe just add fields to the old one?
It will not be reliable to hope that their id will always match) Better add a separate usermeta table and link them to user_id)
create table duplicate:
insert rows:
INSERT IGNORE
INTO users2 (id_user, name, ................)
SELECT
id_user, name, ..................
FROM
users
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question