Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
evanburen
Posting Yak Master
167 Posts |
Posted - 2005-12-02 : 11:03:40
|
| Hello - I don't understand why I'm getting this error message. Thanks.Server: Msg 207, Level 16, State 3, Line 1Invalid column name 'DirName'.SELECT TCompanies.Ticker, TCompanies.Industry, (TDirectors.DirFName + ' ' + TDirectors.DirLName) As DirName, TDirectors.IDDir, TDirectorships.DirStatusFROM TCompanies INNER JOIN TDirectorships ON TCompanies.Ticker = TDirectorships.Ticker INNER JOIN TDirectors ON TDirectorships.IDDir = TDirectors.IDDir WHERE (TDirectors.DirFName LIKE 'richard brown%') OR (TDirectors.DirLName LIKE 'richard brown%') OR (DirName LIKE '%richard brown%') |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2005-12-02 : 11:10:30
|
you can't reference an alias column in a where.you can do:select * from(SELECT TCompanies.Ticker, TCompanies.Industry, (TDirectors.DirFName + ' ' + TDirectors.DirLName) As DirName, TDirectors.IDDir, TDirectorships.DirStatusFROM TCompanies INNER JOIN TDirectorships ON TCompanies.Ticker = TDirectorships.Ticker INNER JOIN TDirectors ON TDirectorships.IDDir = TDirectors.IDDir WHERE (TDirectors.DirFName LIKE 'richard brown%') OR (TDirectors.DirLName LIKE 'richard brown%') ) twhere (DirName LIKE '%richard brown%')Go with the flow & have fun! Else fight the flow |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-12-03 : 02:09:19
|
| or use the same columns in place of DirNameSELECT TCompanies.Ticker, TCompanies.Industry, (TDirectors.DirFName + ' ' + TDirectors.DirLName) As DirName, TDirectors.IDDir, TDirectorships.DirStatusFROM TCompanies INNER JOIN TDirectorships ON TCompanies.Ticker = TDirectorships.Ticker INNER JOIN TDirectors ON TDirectorships.IDDir = TDirectors.IDDir WHERE (TDirectors.DirFName LIKE 'richard brown%') OR (TDirectors.DirLName LIKE 'richard brown%') OR (TDirectors.DirFName + ' ' + TDirectors.DirLName LIKE '%richard brown%')MadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|
|
|