Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

mysql tables

Status
Not open for further replies.

maryer

IS-IT--Management
Jun 10, 2002
16
CY
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
 
Do the tables have the same field names?
Is there a common field in both tables?
Why do you have 2 tables in the first place?

Please be a little more clear in what the situation is and why you want to achieve your goal.

Seems to me that you want to check if an entry exists in both tables before you merge them. Hence the loosing data?

SELECT *
FROM t_one,t_two
WHERE t_one.name = t_two.name

if number of rows returned > 0 then matches found and possible loss in data if merged

Am I on the right path?????
 
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 | |
+--------------+--------------------------------------------

and the 2nd-admin table:
+-----------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-----------+--------------+------+-----+---------+-------+
| id | int(11) | | PRI | 0 | |
| recvdby | varchar(100) | YES | | NULL | |
| recvddate | date | YES | | NULL | |
| assigned | varchar(100) | YES | | NULL | |
| assidate | date | YES | | NULL | |
| complby | varchar(100) | YES | | NULL | |
| compldate | date | YES | | NULL | |
| testby | varchar(100) | YES | | NULL | |
| testdate | date | YES | | NULL | |
| appliedby | varchar(100) | YES | | NULL | |
| appldate | date | YES | | NULL | |
| urlaffect | varchar(255) | YES | | NULL | |
+-----------+--------------+------+-----+---------+-------+

hope this will give u a key what i want to do
thank you in advance
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top