Angelinx Garcx
Angelinx Garcx

Reputation: 1

Update TABLE with INNER JOIN the multi-part identifier could not be bound update inner join

I am trying to write a SQL statement that performs an update with two tables. I have tried with the SELECT statement, and it is working, but with update I get an error:

the multi-part identifier could not be bound update

SELECT cIntrodRefCode, iPayerCompanyID, cIntrodEmail, bGSTApply, *
FROM tblIntroducer
INNER JOIN tblEntity
    ON tblIntroducer.iIntroducerID = tblEntity.iEntityRootID
WHERE cIntrodRefCode = '4'

Update statement not working it shows:

the multi-part identifier could not be bound update

UPDATE t1
SET t1.bGSTApply = 1, t1.cIntrodEmail = '[email protected]', t2.iPayerCompanyID = 7
FROM tblIntroducer AS t1
    INNER JOIN tblEntity AS t2
    ON t1.iIntroducerID = t2.iEntityRootID
WHERE t1.cIntrodRefCode = '4'

I have also tried this one but it also shows the same error

UPDATE tblIntroducer
SET tblIntroducer.bGSTApply = 1, tblIntroducer.cIntrodEmail = '[email protected]', tblEntity.iPayerCompanyID = 7
FROM tblIntroducer
INNER JOIN tblEntity 
    ON tblIntroducer.iIntroducerID = tblEntity.iEntityRootID
WHERE tblIntroducer.cIntrodRefCode = '4'

Upvotes: 0

Views: 58

Answers (1)

Mandana
Mandana

Reputation: 46

UPDATE t1
SET t1.bGSTApply = 1, t1.cIntrodEmail = '[email protected]'
FROM tblIntroducer AS t1
INNER JOIN tblEntity AS t2 ON t1.iIntroducerID = t2.iEntityRootID
WHERE t1.cIntrodRefCode = '4'

go

UPDATE t2
SET t2.iPayerCompanyID = 7
FROM tblIntroducer AS t1
INNER JOIN tblEntity AS t2 ON t1.iIntroducerID = t2.iEntityRootID
WHERE t1.cIntrodRefCode = '4'

you can update one table in every update with join

Upvotes: 1

Related Questions