Update statement for a OUTER JOIN Select Statement.

aniyahudi

New member
Local time
Today, 09:35
Joined
Feb 6, 2014
Messages
4
BH
Hi,
I have the following Select Statement:

SELECT Tenant.ID, Tenant.[First Name], Tenant.[Last Name], Tenant.Address, Tenant.City, Tenant.State, Tenant.Zip, Tenant.[Home Phone], Tenant.[Cell Phone], Tenant.[Work Phone], Tenant.[Rented Unit],
Tenant.[Security Deposit], Tenant.[Move In], Tenant.[Move Out], Tenant.TenantID, Tenant.UnitID, Tenant.PropertyID, Tenant.OwnerID, Owner.Company, Owner.ID AS Expr1, Property.[Property Address],
Units.[Unit Address]
FROM (((Tenant LEFT OUTER JOIN
Units ON Tenant.UnitID = Units.ID) LEFT OUTER JOIN
Property ON Tenant.PropertyID = Property.ID) LEFT OUTER JOIN
Owner ON Tenant.OwnerID = Owner.ID)



And my UPDATE Statement that was generated by the Visual Studio is:



UPDATE Tenant
SET [First Name] = ?, [Last Name] = ?, Address = ?, City = ?, State = ?, Zip = ?, [Home Phone] = ?, [Cell Phone] = ?, [Work Phone] = ?, [Rented Unit] = ?, [Security Deposit] = ?, [Move In] = ?, [Move Out] = ?,
TenantID = ?, UnitID = ?, PropertyID = ?, OwnerID = ?
WHERE (ID = ?) AND (? = 1 AND [First Name] IS NULL OR
[First Name] = ?) AND (? = 1 AND [Last Name] IS NULL OR
[Last Name] = ?) AND (? = 1 AND Address IS NULL OR
Address = ?) AND (? = 1 AND City IS NULL OR
City = ?) AND (? = 1 AND State IS NULL OR
State = ?) AND (? = 1 AND Zip IS NULL OR
Zip = ?) AND (? = 1 AND [Home Phone] IS NULL OR
[Home Phone] = ?) AND (? = 1 AND [Cell Phone] IS NULL OR
[Cell Phone] = ?) AND (? = 1 AND [Work Phone] IS NULL OR
[Work Phone] = ?) AND (? = 1 AND [Rented Unit] IS NULL OR
[Rented Unit] = ?) AND (? = 1 AND [Security Deposit] IS NULL OR
[Security Deposit] = ?) AND (? = 1 AND [Move In] IS NULL OR
[Move In] = ?) AND (? = 1 AND [Move Out] IS NULL OR
[Move Out] = ?) AND (? = 1 AND TenantID IS NULL OR
TenantID = ?) AND (? = 1 AND UnitID IS NULL OR
UnitID = ?) AND (? = 1 AND PropertyID IS NULL OR
PropertyID = ?) AND (? = 1 AND OwnerID IS NULL OR
OwnerID = ?)


Now, I know that something in the UPDATE statement does not match my select statement.
What should my Update Statement be, in order to update all the columns in the joined tables?

I've also posted this question in asp.net, but so far I have not received an answer.
Thanks so much for your help.
Aron
 
What fields do you want to UPDATE?
You have several tables in your Select sql.
 
BH
jdraw, thanks for your reply. I would like to update all fields from the SELECT statement.
Thanks
Aron
 

Users who are viewing this thread

Back
Top Bottom