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

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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T15:40:16+00:00 2026-05-28T15:40:16+00:00

Right now I have a mysql database with a table userphone(id, phone, type,userid) and

  • 0

Right now I have a mysql database with a table userphone(id, phone, type,userid) and I’d like to split it into two tables, phone(id,phone,type) and user_phone(id,user_id,phone_id).

I’m doing this because I’m going to have other things that also refer to phone numbers, and they ought to be all stored in one table. (e.g. I’ll also be adding a company_phone(id,company_id,phone_id) join table to join companies with their phone numbers).

Is there any good, efficient way of doing this? I’ve added the new tables, but am not sure of the best approach for populating them.

I can add all the phones from userphone into the phone table with something like

INSERT INTO phone(phone,type) SELECT phone,type FROM userphone;

but that doesn’t add an entry into the new user_phone table for each phone.

Is there any way to INSERT INTO two different tables at once? (from research, I know there isn’t, but I can’t figure out how else to accomplish this…)

Thanks in advance!

  • 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-05-28T15:40:18+00:00Added an answer on May 28, 2026 at 3:40 pm
    1. Create the table user_phone as

      insert into phone(phone,type,user_id)
      select phone,type,user_id from userphone
      
    2. Create your table user_phone as

      insert into user_phone (user_id,phone_id)
      select user_id,id from phone
      
    3. alter table phone drop column user_id

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

Sidebar

Related Questions

I have a MySQL database with two tables (simplified for this question): movies table
I'm making a cocktail database, and right now I have three tables: drinks has
Right now in a database I have a Members table and a Products table
Lets say I have two MySQL databases with some complex table structures. Neither database
Right now, if I want to run mysql, I have to do /Applications/MAMP/Library/bin/mysql -u
Right now I have a database (about 2-3 GB) in PostgreSQL, which serves as
Right now I have a few new applications being developed against an Oracle Database,
Right now I have a table called Campaigns that has many Hits, if I
I have two tables: A table of restaurants and a table of areas. The
I have a MySQL database/table set up and a .php file online that inserts

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.