Timeline for How and what is the most efficient way to join two tables, retaining a particular field from both?
Current License: CC BY-SA 3.0
10 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Feb 26, 2013 at 7:26 | history | tweeted | twitter.com/#!/StackDBAs/status/306304292980129792 | ||
Feb 25, 2013 at 11:46 | vote | accept | Xefan | ||
Feb 25, 2013 at 11:41 | comment | added | Xefan | Hi adhocgeek, I think you've probably found the solution, I wasn't aware of full outer join, only outer join and full join as separate entities. It appears this does something I was considering doing into a single operation - combines left and right joins into one which gets me part way towards a solution. I now need to be able to group by whichever table's entry for component isn't null. | |
Feb 25, 2013 at 11:36 | answer | added | ypercubeᵀᴹ | timeline score: 4 | |
Feb 25, 2013 at 11:30 | comment | added | adhocgeek | A full outer join should retain rows from table 1 and table 2 which have no corresponding row in the other table. How is it not working for you? Are you joining on ID rather than Component? | |
Feb 25, 2013 at 11:11 | history | edited | Xefan | CC BY-SA 3.0 |
edited title
|
Feb 25, 2013 at 11:09 | comment | added | Xefan | There's no guarantee that a component will be present in both tables and that's why I've been unable to simply use an outer join, which would suffice if one table was guaranteed to have all possible components. Effectively each table may have a subset of components, but I need to produce a summary table which lists all components showing summary data for each, filling in with 0 where there is no entry in table 1 or table 2 for that component. I noticed I mentioned primary key in the topic, that's wrong, component isn't a key - ID is. Edited to reflect this. | |
Feb 25, 2013 at 10:46 | comment | added | András Váczi | Is Component1 present in both tables? If yes, how do you identify it in each table? If no, how do you get data3 and data4 for Component1? | |
Feb 25, 2013 at 10:26 | review | First posts | |||
Feb 25, 2013 at 12:57 | |||||
Feb 25, 2013 at 10:06 | history | asked | Xefan | CC BY-SA 3.0 |