List:General Discussion« Previous MessageNext Message »
From:<ross Date:June 19 2007 12:13pm
Subject:Re: selecting everyting from 2 non-identical tables.
View as plain text  
My frist post was not worded correctly. I cannot join two tables as all the 
rows are unique.

men

id
height
name
age
fav team


1 - 176cm - John - 25-lakers
2 - 180cm - Rob -  40-yankies


women

id
height
name
age
no_of_children

3 - 166cm - mary - 22 - 2
4 - 175cm - betty - 48 - 4


I want to display all the attributes of all the people even if  they are 
null my final table should be


1 - 176cm - John - 25-null-lakers
2 - 180cm - Rob -  40-null-yankies
3 - 166cm - mary - 22 - 2-null
4 - 175cm - betty - 48 - 4-null




Ross

----- Original Message ----- 
From: "Jay Blanchard" <jblanchard@stripped>
To: <ross@stripped>; <mysql@stripped>
Sent: Tuesday, June 19, 2007 12:58 PM
Subject: RE: selecting everyting from 2 non-identical tables.


[snip]
I have two non-identical tables. They are pretty similar except a few
fields.  I want to select everything from both for example

table1

id
name
age


table2

id
name
height


I want

id
name
height
age


even if it returns null values. select * from table1, table2 seems to
give repeat rows for some reason.
[/snip]

Use a left outer join, assuming that 'name' is the same in both;

SELECT t1.id, t1.name, t1.age, t2.height
FROM table1 t1 LEFT OUTER JOIN table2 t2
ON(t1.name = t2.name)


Thread
selecting everyting from 2 non-identical tables.ross19 Jun
  • RE: selecting everyting from 2 non-identical tables.Jay Blanchard19 Jun
    • Re: selecting everyting from 2 non-identical tables.ross19 Jun
      • Re: selecting everyting from 2 non-identical tables.Olexandr Melnyk19 Jun
        • Re: selecting everyting from 2 non-identical tables.Mogens Melander20 Jun
  • Re: selecting everyting from 2 non-identical tables.Olexandr Melnyk19 Jun