I have 2 tables. Auth and User
Auth has the ff. columns (source) 18883 rows
id | username | password
User has the ff. columns (destination) 18868 rows
id | username | first name | last name | email
hmmm
auth.id = user.id
auth.username = user.username
Now for some reason the User table has rows where some username is missing.
What I want to do is make a script that looks for missing rows on User and insert the id and username from Auth and insert first name=’fname’, last name=’lname’, email=’name@domain.com’.
So both tables will have the same number of rows and be in sync.
Thank you.
You are unclear about what is missing . . . the id or the username or both. Assuming the username specifies missing, the following query does what you want:
This assumes that username is not duplicated in the user table.
It seems strange that the column called “id” would have the same values in both tables. You should revisit your data structure to see if this is really the case. More often than not, “id” would be an auto-incremented primary key.