mySQL
how combine 2 tables with equal structures?
combine 2 tables
Started by famer, Nov 11 2005 03:42 PM
8 replies to this topic
#1
Posted 11 November 2005 - 03:42 PM
#2
Posted 11 November 2005 - 04:43 PM
what do you mean combine? you mean transfer the data from one table into another?
i dont know if there is a quicker way but i would just download a backup of the whole database and take the relevant section containing the info for the 2nd table and run the query on the 1st table.
i dont know if there is a quicker way but i would just download a backup of the whole database and take the relevant section containing the info for the 2nd table and run the query on the 1st table.
#3
Posted 11 November 2005 - 05:48 PM
The more complicated automated way would be to run a loop taking out all the data from one table and during that loop, insert it into the other table with the nested fields.
#4
Posted 12 November 2005 - 05:55 AM
I mean join, i just think that mysql have a command for it.
ok i'll do it with a script.
thanx
ok i'll do it with a script.
thanx
#5
Posted 12 November 2005 - 08:06 AM
It does...its like:
Or so...and the table1.field MUST be the same as table2.field...such as most tables have an ID column.
SELECT * FROM table1, table2 WHERE table1.field = table2.field
Or so...and the table1.field MUST be the same as table2.field...such as most tables have an ID column.
#6
Posted 12 November 2005 - 08:16 AM
no the code u want is :
Quote
SELECT `colums` INTO `new_tbl_name` FROM `tables` WHERE `table1.id` = `table1.id`;
#7
Posted 12 November 2005 - 12:58 PM
If he wants to select stuff from multiple tables at once, then darth's code is right.
Since i don't know much about SELECT INTO, i can only assume that would select everything from `tables` and paste it into the `new_tbl_name`.
So depending on what needs to be done, you both may be correct. My simple suggestion would be to look at the following links, and then bookmark them.
http://dev.mysql.com...sql-syntax.html
http://www.w3schools.../sql_select.asp
Since i don't know much about SELECT INTO, i can only assume that would select everything from `tables` and paste it into the `new_tbl_name`.
So depending on what needs to be done, you both may be correct. My simple suggestion would be to look at the following links, and then bookmark them.
http://dev.mysql.com...sql-syntax.html
http://www.w3schools.../sql_select.asp
#8
Posted 12 November 2005 - 01:21 PM
well darths is just selecting from tables. Farmer wanted to combine two tables, and u can select multiple tables with the SELECT INTO, then u just make the new table and then u can delete the others after.
#9
Posted 12 November 2005 - 02:50 PM
great!
thanx
thanx
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users
