Click here to Skip to main content
15,881,812 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello, so i'm currently working on a mvc project using codesmith. Specifically im working on my branch called FmCurrencyRate where i insert the rates of currencies and dates in a grid etc.. I am told to modify the view on sql --> v_fm_currency_rate, so i can get the code of each currency but from another table, which is fm_currency. Which is the correct code to do it?
(p.s the table currency_rate has only int columns, so thats the reason why i need the codes from the other table so in my grid the codes can be shown and not the id's of the currencies)

What I have tried:

ALTER view [dbo].[v_fm_currency_rate] 
as
SELECT id, from_currency_id, to_currency_id, value, rate_date, user_created, date_created, user_updated, date_updated, p2.code as fromCurrencyCode
FROM   dbo.fm_currency_rate p1
INNER JOIN fm_currency p2
ON ...
GO
Posted
Updated 27-May-21 4:33am
Comments
SeanChupas 27-May-21 10:08am    
Sounds like you just need to join tables. Very easy but since I can't see your tables or your table structure, I don't know what fields to join on.

Do you know basic SQL? If so, this should be very easy.
xristos ratsas 27-May-21 10:19am    
yep, i solved it, i just needed a new variable p3 and second inner join to do it ^^
that was the solution : INNER JOIN fm_currency p2
ON p1.from_currency_id=p2.id
INNER JOIN fm_currency p3
ON p1.to_currency_id=p3.id

1 solution

As mentioned in the comments, getting the correct join will get the value you seek.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900