Merging some columns of two mysql tables where id = fileid
- by garg
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
The result should be:
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?