Hello there
i have 2 mysql tables, How can i merge them into one without losing any data. Should I make ALTER 1st table and add the same fields the 2nd table has and then how can i transfer all datas from the 2nd to the 1st table.
Thank you in advance
I have two tables for the one same form. one is request part and another is admin part which has to be filled by admin when request part is done. They both have different fields only id number is common for them. So it can be a lot of requests and only by time admin part for those request.id can be filled. i kept 2 separate tables so far but now i need to merge them into one and just UPDATE new_table when i want to fill out admin (new fields) part. For cliarlier explanation i want to put here description of those tables:
request table:
+--------------+-----------------------------------------------------+
| Field | Type
| Null | Key | Default | Extra |
+--------------+-----------------------------------------------------+
| id | int(11)
| | PRI | NULL | auto_increment |
| name | varchar(100)
| YES | | NULL | |
| organization | varchar(100)
| YES | | NULL | |
| site | enum('bla','bla')
| YES | | NULL | |
| department | enum('bla','bla','bla','bla','bla','bla') | YES | | NULL | |
| email | varchar(255)
| YES | | NULL | |
| reqdate | date
| YES | | NULL | |
| needdate | date
| YES | | NULL | |
| url | varchar(255)
| YES | | NULL | |
| description | text
| YES | | NULL | |
| timestamp | timestamp(14)
| YES | | NULL | |
+--------------+--------------------------------------------
i.e if you have details in tableA with id 1, do the details in table B id 1 belong to its table a partner?
if so, is this true for the whole recordset?
We can then select table A id=1 where table b id=1 to give us related records.
Are you going to make a completely new table or modify one of the existing ones?
Alter your table to add the fields required (or make a new table so that there is no risk of data loss if your query is wrong).
INSERT INTO new_table (field1,field2,field3,etc,etc) SELECT a.field1,a.field2,a.field3,b.field1,b.field2,b.field3) FROM TABLE_A a, TABLE_B b where a.id = b.id;
***************************************
Party on, dudes!
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.