Jump to content
xisto Community
Sign in to follow this  
farsiscript

Merge 2 Table In Mysql Question

Recommended Posts

Hi Dears
i have one question about mysql and table
how can merge 2 table in mysql for example i have 2 table with this fields

table 1 :

CREATE TABLE cd1 (id tinyint(4) NOT NULL auto_increment,
cat text NOT NULL,
text text NOT NULL,
image text NOT NULL,
cd text NOT NULL,
price text NOT NULL,
space text NOT NULL,
company text NOT NULL,
name text NOT NULL,
rate int NOT NULL,
PRIMARY KEY (id)
) TYPE=MyISAM;


Tabel 2 :

CREATE TABLE cd2 (id tinyint(4) NOT NULL auto_increment,
cat text NOT NULL,
text text NOT NULL,
image text NOT NULL,
cd text NOT NULL,
price text NOT NULL,
space text NOT NULL,
company text NOT NULL,
name text NOT NULL,
rate int NOT NULL,
PRIMARY KEY (id)
) TYPE=MyISAM;


In table 2 i have many (1200) records and row but in table 1 i have 200 row
i want bind this 2 table and make one tabel with (1400) row , how can do this ?
with command ? with script or with phpmyadmin ?
thanks all :)

Share this post


Link to post
Share on other sites

Try phpadmin. I am sure you can have it perform a backup of the smaller table with the structure included. This will create a text file containing all the SQL neccessary to Create the table and also provides the neccessary INSERT commands. Then Modify the text file which it has created to :1) remove the CREATE TABLE command and 2) Edit to remove the id's from the records, since this may cause some problems if you have duplicate id's. Use find / replace?3) Use find/replace as required to point to the larger of the Tables and issue the INSERT commands against the second table instead of the first. Voila! The updated table should contain both sets of data. You might then DROP the smaller table or keep it as a backup, but check to make sure the transfer was successful, first

Share this post


Link to post
Share on other sites

similar to what is already said i belive you can export data from phpmyadmin and then import it from a text file. Has the same effect as already posted but much easier to do. hope that helps a bit as well.

Share this post


Link to post
Share on other sites

Hi Dear shadowxYes i use phpmyadmin , but i get export form database and i want import in to large database , but in phpmyadmin export page . we have 3 options (instert , update , Replace )i Read your note (i know i must use insert ) but if you have more info about this 3 Options please post hereReally thanks , your post is very nice

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.