This is a discussion on how do I combine 2 tables???? within the MySQL Database forums, part of the Database Forums category; hey everyone, I know this is a total noob question but please help. I have 2 tables that I was ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
hey everyone, I know this is a total noob question but please help.
I have 2 tables that I was given that I would like to combine into one. Although both tables have different columns, they both have one column that is the same for both (an id column) and there is a one to one relationship between the tables although one table has slightly more records than the other so when I do combine them there will be some null values. please help me with the SQL for merging these two tables together on the common column thanks a ton |
|
|||
|
On Thu, 10 Jan 2008 18:50:04 -0800 (PST), agilehack
<jason.rabolli@gmail.com> wrote: >hey everyone, I know this is a total noob question but please help. > >I have 2 tables that I was given that I would like to combine into >one. Although both tables have different columns, they both have one >column that is the same for both (an id column) and there is a one to >one relationship between the tables although one table has slightly >more records than the other so when I do combine them there will be >some null values. please help me with the SQL for merging these two >tables together on the common column > >thanks a ton INSERT INTO newtable (id,col1,col2) SELECT id,col1 FROM table1 LEFT OUTER JOIN table2 ON (id); http://dev.mysql.com/doc/refman/5.0/...rt-select.html http://dev.mysql.com/doc/refman/5.0/en/join.html HTH -- ( Kees ) c[_] The secret of being miserable is to have leisure to bother about whether you are happy or not. The cure for it is occupation. (George Bernard Shaw 1856-1950) (#472) |