October 9, 2005 at 7:57 pm
I have the following query. The facts are that there is a value of 164 in the Account Table for the RelAccLocal Column. My query unfortunately is returning 0 for this field when the values really is 164.
I thought this is how the LEFT OUTER JOIN is suppose to work? Can someone tell me what am I doing wrong?
DECLARE @AccountID INT
SET @AccountID = 9290
SELECT A.AccountName, ISNULL(A2.AccountID, 0) AS 'RelAccLocalID', ISNULL(A2.AccountName, ''), ATypes.AccountTypeID,
ATypes.AccountTypeDesc
FROM Account A INNER JOIN AccountTypes ATypes ON A.AccountTypeID = ATYpes.AccountTypeID
LEFT OUTER JOIN Account A2 ON A.AccountID = A2.RelAccLocal
WHERE A.AccountID = @AccountID
October 9, 2005 at 8:19 pm
Maybe ...
DECLARE @AccountID INT
SET @AccountID = 9290
SELECT A.AccountName, ISNULL(A2.AccountID, 0) AS 'RelAccLocalID', ISNULL(A2.AccountName, ''), ATypes.AccountTypeID, ATypes.AccountTypeDesc FROM Account A INNER JOIN AccountTypes ATypes ON A.AccountTypeID = ATYpes.AccountTypeID LEFT OUTER JOIN Account A2 ON A.RelAccLocal = A2.AccountID WHERE A.AccountID = @AccountID
--------------------
Colt 45 - the original point and click interface
October 9, 2005 at 8:26 pm
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply