Is there any way to JOIN two rows from a single table to a single row, based on two columns.
I built a scrappy little data base for my business, and I finally ran into a situation where I thought I had built in the necessary extensibility. Unfortunately, I found out pretty fast that I can't use the JOIN as I was before now that I need to join info from two columns to a single row (previously, I was only joining on one column).
Here is what I have:
| Name | ID | ID_2 |
|----- |---------| --------|
| Jake | a | b |
| Jane | b | c |
| John | c | NULL |
ID | Info
-----------
a | 1
b | 3
c | 5
And here is what I'm looking for:
Name | Info_1 | Info_2
--------------------------
Jake | 1 | 3
Jane | 3 | 5
John | 5 | NULL
Or, better yet, this:
Name | Info_Sum
---------------
Jake | 4
Jane | 8
John | 5