Jump to content

Archived

This topic is now archived and is closed to further replies.

mokahola

Merging two SQL result tables that have the same fields

Recommended Posts

Hi,

I have two tables, one for patches and one for mods, I want to merge these into one table.  Each has the same structure, as follows:

+-----------+-----------+-----------+
| name        | adddate    | views      |
+-----------+-----------+-----------+
|<name>    | <date>      | <views>  |
|<name>    | <date>      | <views>  |
+-----------+-----------+-----------+

Now I want to combine them so that all the information is in one table, so I can order them by the adddate, and that the names of the patches and the names of the mods are in the same [name] column. The same goes for the other columns.

I searched the internet and couln't find any thing about it, so maybe it isn't even possible.

Thanks in advance.

mokahola.

Share this post


Link to post
Share on other sites
INSERT INTO table1
SELECT *
FROM table2

Rename table1/table2 appropriately.
table2 is the second table you want to merge with table 1.
Then empty table2 and delete it.

Share this post


Link to post
Share on other sites
thnx, but I didn't want it in there permenently, but I fond a way:

SELECT * FROM mods
UNION ALL
SELECT * FROM patches ORDER BY adddate

Share this post


Link to post
Share on other sites

×

Important Information

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.