O
O
Owl__Nebula2015-06-01 01:43:45
SQL
Owl__Nebula, 2015-06-01 01:43:45

How to query on three tables in SQL Server?

There are three tables: Credit_Rah, Valuta and Cred_zaborg. Valuta is associated with Credit_rah, Credit_rah with Cred_zaborg.
You need to set Cred_zaborg.Suma_zaborg=Valuta.Kurs*Cred_zaborg.Suma_zaborgVAL
There is a request:

select Credit_Rah.Credit_rah, kurs*Suma_zaborgVAL as SumaUAH
into C
from valuta 
inner join credit_rah on Credit_Rah.Valuta_name=Valuta.Valuta_code
inner join cred_zaborg on Credit_Rah.Credit_rah=Cred_zaborg.Credit_rah;
update cred_zaborg 
set Suma_zaborg = SumaUAH
where cred_zaborg.credit_rah=C.credit_rah

Problem:
SumaUAH - invalid column name
C.credit_rah - The multi-part identifier could not be bound.
How to solve it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Lastochkin, 2015-06-01
@Owl__Nebula

update cred_zaborg 
set Suma_zaborg = kurs*Suma_zaborgVAL
from cred_zaborg 
inner join credit_rah on Credit_Rah.Credit_rah=Cred_zaborg.Credit_rah
inner join valuta  on Credit_Rah.Valuta_name=Valuta.Valuta_code

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question