how do I combine 2 tables????

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 ...


Go Back   Usenet Forums > Database Forums > MySQL Database

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 01-11-2008
agilehack
 
Posts: n/a
Default how do I combine 2 tables????

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
Reply With Quote
  #2 (permalink)  
Old 01-11-2008
Kees Nuyt
 
Posts: n/a
Default Re: how do I combine 2 tables????

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)
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 08:30 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0