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 8518445
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T05:58:46+00:00 2026-06-11T05:58:46+00:00

There are two tables TableA filedata_id | user_id | filename 1 | 1 |

  • 0

There are two tables

TableA
filedata_id | user_id | filename
1           | 1       | file.txt
2           | 1       | file2.txt


TableB   
a_id        | date    | filedataid | counter | state | cat_id | subcat_id | med_id
99          | 1242144 | 1          | 2       | v     | 55     |  56       | 90
100         | 1231232 | 2          | 3       | i     | 44     |  55       | 110

I want to move columns cat_id, subcat_id, med_id to TableA where tableA.filedata_id = TableB.filedataid

edit: The result should be a schema change in tableA so it looks like the following and also have the data from those columns in tableB:

TableA
filedata_id | user_id | filename  | cat_id | subcat_id | med_id
1           | 1       | file.txt  | 55     | 56        | 90
2           | 1       | file2.txt | 44     | 55        | 110

and so on.

Is there a way to do this easily?

  • 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-11T05:58:47+00:00Added an answer on June 11, 2026 at 5:58 am


    You can use INNER JOIN for that:

    SELECT t1.filedata_id, t1.user_id, t1.filename
          ,t2.cat_id, t2.subcat_id, t2.med_id
    FROM TableA t1 
    INNER JOIN TableB t2 
    ON t1.filedata_id = t2.filedataid
    

    See this SQLFiddle

    UPDATE:

    You can change the schema of TableA like this:

    ALTER TABLE TableA
    Add column cat_id int, 
    Add column  subcat_id int, 
    Add column  med_id int;
    

    And update new columns of TableA from TableB like this:

    UPDATE tableA t1 
           JOIN tableB t2 
           ON t1.filedata_id = t2.filedataid
    SET t1.cat_id = t2.cat_id,
        t1.subcat_id = t2.subcat_id,
        t1.med_ID = t2.med_ID;
    

    See this SQLFiddle

    For more see MySQL: ALTER TABLE Syntax and MySQL: UPDATE Syntax.

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

Sidebar

Related Questions

I have two tables TableA aId aValue TableB bId aId bValue I want to
I have two tables, tableA and tableB, linked through a locationID. TableA has descriptive
I have two tables called TableA and TableB. TableA has the following fields: TableA_ID
I have two tables, TableA and TableB: CREATE TABLE `TableA` ( `shared_id` int(10) unsigned
Suppose I have these two tables : TABLEA TABLEB ----------- ----------- ID | NAME
I have two tables ..TableA and TableB in TableA.. I have 5 fields.. (
I have two tables : TableA TableB id id amt amt idUser idTableA Let's
I have two tables TableA and TableB. Now TableA has 2 columns: ID &
I have two tables tableA and tableB, which have the same structure: rowid: big
I am trying to look through two tables TableA and TableB get print out

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.