|
Posted by Dan Guzman on 10/02/89 11:51
> select [t1.*],[t2.userid] as [userid2],[t2.approved],[t2.type]
> from [tblMembers] as t1 left outer join [tblProfiles] as t2
> on [t1.userid]=[t2.userid]
The main problem here is that you are enclosing both the table alias and
column name. Try:
SELECT
[t1].*,
[t2].[userid] AS [userid2],
[t2].[approved],
[t2].[type]
FROM [tblMembers] AS [t1]
LEFT OUTER JOIN [tblProfiles] AS [t2]
ON [t1].[userid] = [t2].[userid]
--
Hope this helps.
Dan Guzman
SQL Server MVP
"Sfj" <shermanfj@yahoo.com> wrote in message
news:6h2lg.112415$Ce1.107196@dukeread01...
> Hello folks,
>
> Old programmer learning new tricks.
>
> I think similar issues have been posted, but I would like to ask some help
> with the following code...
>
> select [t1.*],[t2.userid] as [userid2],[t2.approved],[t2.type]
> from [tblMembers] as t1 left outer join [tblProfiles] as t2
> on [t1.userid]=[t2.userid]
> where ...
>
> I get the following error...
>
> [Microsoft][ODBC SQL Server Driver][SQL Server]Invalid column name
> 't1.userid'.
>
> ...but there is a [userid] in both tables. Do I have to make them keys or
> something? And I need to do work (add and update) on both tables after
> the values are returned.
>
> Also, how bad is my syntax? If you could give advice on removing
> extraneous brackets and I would like to not have to use the "as" clause.
> I really just want to keep it simple. Whatever works though.
>
> Thanks
>
Navigation:
[Reply to this message]
|