This is driving me nuts, I’m sure it’s rather simple but can’t get it right.
Having a table holding ratevalues for different years:
Ratevaluetable
Year Value A Value B Value C
2009 10 15 20
2010 12 18 22
2011 14 21 25
Then I have another persontable:
User Time Price
john 2010 value B
Tina 2009 Value C
Bill 2011 Value C
Now what I need is to join the 2 tables so that I get the value in the Price column substituted with the data from the Ratevaluetable.
I can join on time on year, but the I don’t know how to join to the Value fields?
This is not possible with your current database schema. Joins connect tables by matching column values; what you propose to do here is match a column value with a column name, which is impossible.
What would be possible is:
Given the above schema, you could join
UsertoRateValueTablein the obvious manner.