HawaiiDragon
asked on
sql update in a select across a Join
Hello All.
I am trying to do an update on one table when there is a matching record in another table on a diffrent database below is my code. She builds find but does not work ... any IDEAS?
I am trying to do an update on one table when there is a matching record in another table on a diffrent database below is my code. She builds find but does not work ... any IDEAS?
SELECT a.*, b.*
FROM dbo.tblPayment AS a INNER JOIN
GradAPP.dbo.Student_INFO AS b ON a.IP = b.IP
WHERE (a.PaymentType = 2)
UPDATE b
SET b.PaymentStatus = 1
WHERE (a.Successfull = 1) AND (b.PaymentStatus = 0)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
UPDATE GradAPP.dbo.Student_INFO
SET PaymentStatus = 1
WHERE exists (select ip from WDB_CCPayment.dbo.tblpayme nt as a
where a.Successful = 1
and a.ip=GradAPP.dbo.Student_I NFO.ip
and a.paymenttype=2)
AND PaymentStatus = 0
Low fat you rock!!!
SET PaymentStatus = 1
WHERE exists (select ip from WDB_CCPayment.dbo.tblpayme
where a.Successful = 1
and a.ip=GradAPP.dbo.Student_I
and a.paymenttype=2)
AND PaymentStatus = 0
Low fat you rock!!!
ASKER
UPDATE GradAPP.dbo.Student_INFO
SET PaymentStatus = 1
WHERE exists (select ip from WDB_CCPayment.dbo.tblpayme nt as a
where a.Successful = 1
and a.ip=GradAPP.dbo.Student_I NFO.ip
and a.paymenttype=2)
AND PaymentStatus = 0
Low fat you rock!!!
SET PaymentStatus = 1
WHERE exists (select ip from WDB_CCPayment.dbo.tblpayme
where a.Successful = 1
and a.ip=GradAPP.dbo.Student_I
and a.paymenttype=2)
AND PaymentStatus = 0
Low fat you rock!!!
ASKER
error
Msg 4104, Level 16, State 1, Line 1
The multi-part identifier "Wdb_CCPayment.dbo.tblPaym
Msg 4104, Level 16, State 1, Line 1
The multi-part identifier "Wdb_CCPayment.dbo.tblPaym
Open in new window