Re: selecting everyting from 2 non-identical tables.
On Tue, June 19, 2007 23:42, Olexandr Melnyk wrote: > 2007/6/19, [EMAIL PROTECTED] <[EMAIL PROTECTED]>: >> >> My frist post was not worded correctly. I cannot join two tables as all >> the >> rows are unique. > > > What's wrong with my solution? > > 2007/6/19, Olexandr Melnyk <[EMAIL PROTECTED]>: >> >> select id, name, age, null as height >> from table1 >> union >> select id, name, null as age, height >> from table2 I believe that was the right answer to the question. ( there might be other answers ;^) -- Later Mogens Melander +45 40 85 71 38 +66 870 133 224 -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: selecting everyting from 2 non-identical tables.
2007/6/19, [EMAIL PROTECTED] <[EMAIL PROTECTED]>: My frist post was not worded correctly. I cannot join two tables as all the rows are unique. What's wrong with my solution? 2007/6/19, Olexandr Melnyk <[EMAIL PROTECTED]>: select id, name, age, null as height from table1 union select id, name, null as age, height from table2 -- Sincerely yours, Olexandr Melnyk http://omelnyk.net/
Re: selecting everyting from 2 non-identical tables.
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" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]>; 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) -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: selecting everyting from 2 non-identical tables.
select id, name, age, null as height from table1 union select id, name, null as age, height from table2 2007/6/19, [EMAIL PROTECTED] <[EMAIL PROTECTED]>: select * from table1, table2 seems to give repeat rows for some reason. It is a Cartesian product. -- Sincerely yours, Olexandr Melnyk http://omelnyk.net/
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) -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
selecting everyting from 2 non-identical tables.
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. Thanks, R.