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

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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T03:31:23+00:00 2026-06-09T03:31:23+00:00

I have 2 tables. Auth and User Auth has the ff. columns (source) 18883

  • 0

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.

  • 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-06-09T03:31:25+00:00Added an answer on June 9, 2026 at 3:31 am

    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:

    insert into user(id, uesrname, firstname, lsatname, email)
        select a.id, a.username. 'fname', lname', 'name@domain.com'
        from auth a left outer join
             user u
             on a.username = u.username
        where u.id is null
    

    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.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following two tables: auth_user id username is_active (boolean) ... useprofile_userprofile id
I am using CakePHP 2.0's integrated Auth component. I have the following tables :
I have tables like this: tblUsers int UserID string UserName tblUsersInRoles int UserID int
I have tables linked by FK, I query on the first table using entity
I have tables Product ( ID, CategoryID, ... ) Category ( ID, Name, ..
I have a MySQL table which has three columns: Authority | MapID | Time
I need to upadte, add and delete rows from the auth.models.User table, unfortunately... when
I have developed a grails/groovy application for a legacy database which has user maintenance
I have 4 tables: stores {id, name, owner_id, city_id, ...} store_managers {id, store_id, user_id,
I have two cakephp2 applications running on same database, but having different Auth tables

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.