|
database
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Help joining 3 different tables...I am trying to join three different tables on common column names, with a
Group by clause on the first table. This is the error I keep getting The column prefix "column name" does not match with a table name or alias name used in the query. Any help will be greatly appreciated! -- The Saint MCP, MCDST, MCSA, CCNA Post a simplified version of your query and we can probably assist...
-- Show quoteTibor Karaszi, SQL Server MVP http://www.karaszi.com/sqlserver/default.asp http://www.solidqualitylearning.com/ "The Saint" <thesa***@discussions.microsoft.com> wrote in message news:56B18006-4A01-4CB0-8522-CB7DC506CA85@microsoft.com... >I am trying to join three different tables on common column names, with a > Group by clause on the first table. This is the error I keep getting > > The column prefix "column name" does not match with a table name or alias > name used in the query. > > Any help will be greatly appreciated! > -- > The Saint > MCP, MCDST, MCSA, CCNA It would help us better assist you if you could include table DDL, query
strategy used so far, sample data in the form of INSERT statements, and an illustration of the desired results. (For help with that refer to: http://www.aspfaq.com/5006 ) The less 'set up' work we have to do, the more likely you are going to have folks tackle your problem and help you. Without this effort from you, we are just playing guessing games. One 'guess' is that you have "[Column Name]" preceding a ColumnName, e.g., [Column Name].ColumnName. -- Show quoteArnie Rowland, Ph.D. Westwood Consulting, Inc Most good judgment comes from experience. Most experience comes from bad judgment. - Anonymous "The Saint" <thesa***@discussions.microsoft.com> wrote in message news:56B18006-4A01-4CB0-8522-CB7DC506CA85@microsoft.com... >I am trying to join three different tables on common column names, with a > Group by clause on the first table. This is the error I keep getting > > The column prefix "column name" does not match with a table name or alias > name used in the query. > > Any help will be greatly appreciated! > -- > The Saint > MCP, MCDST, MCSA, CCNA Use Database 1
select Column1, Count(Column2) AS NewName, Column3, Column4 from Table1 with (nolock) inner join Table2 with (nolock) on Table1.ColumnName = Table2.ColumnName inner join Database2.dbo.Table3 with (nolock) on Table2.ColumnName = Table3.ColumnName inner join Database3.dbo.Table4 with (nolock) on Table4.ColumnName = Table3.ColumnName where (Table2.Column2 IN ('1', '2', '3', '4', '5', '7', '8', '9', '11', '12', '13', '14', '15', '16', '23', '32')) and (Table3.ColumnName = 'Parameter') Group By Column1, Column3, Column4 Order By Column1, Column3, Column4 I hope this will do..... The error I keep getting reads... The column prefix 'ColumnName' does not match with a table name or alias name used in the query. THANKS!!! -- Show quoteCipherTeKST MCSE, CCNA "Arnie Rowland" wrote: > It would help us better assist you if you could include table DDL, query > strategy used so far, sample data in the form of INSERT statements, and an > illustration of the desired results. (For help with that refer to: > http://www.aspfaq.com/5006 ) > > > The less 'set up' work we have to do, the more likely you are going to have > folks tackle your problem and help you. Without this effort from you, we are > just playing guessing games. > > One 'guess' is that you have "[Column Name]" preceding a ColumnName, e.g., > [Column Name].ColumnName. > > -- > Arnie Rowland, Ph.D. > Westwood Consulting, Inc > > Most good judgment comes from experience. > Most experience comes from bad judgment. > - Anonymous > > > "The Saint" <thesa***@discussions.microsoft.com> wrote in message > news:56B18006-4A01-4CB0-8522-CB7DC506CA85@microsoft.com... > >I am trying to join three different tables on common column names, with a > > Group by clause on the first table. This is the error I keep getting > > > > The column prefix "column name" does not match with a table name or alias > > name used in the query. > > > > Any help will be greatly appreciated! > > -- > > The Saint > > MCP, MCDST, MCSA, CCNA > > > You need to prefix the Columns in the select and the group by with the table
name. i,.e. select table1.colum, table1.coulmn2 .... group by table1.colum, table1.coulmn2 Immy Show quote "CipherTeKST" <CipherTe***@discussions.microsoft.com> wrote in message news:F7A2B04B-B3EC-4AF6-83B0-E2D172EFE9F4@microsoft.com... > Use Database 1 > > > select Column1, Count(Column2) AS NewName, Column3, Column4 > from Table1 with (nolock) > > inner join Table2 with (nolock) > on Table1.ColumnName = Table2.ColumnName > > inner join Database2.dbo.Table3 with (nolock) > on Table2.ColumnName = Table3.ColumnName > > inner join Database3.dbo.Table4 with (nolock) > on Table4.ColumnName = Table3.ColumnName > > where (Table2.Column2 IN ('1', '2', '3', '4', '5', '7', '8', '9', '11', > '12', '13', '14', '15', '16', '23', '32')) > and (Table3.ColumnName = 'Parameter') > > Group By Column1, Column3, Column4 > > Order By Column1, Column3, Column4 > > > I hope this will do..... > > The error I keep getting reads... > > The column prefix 'ColumnName' does not match with a table name or alias > name used in the query. > > THANKS!!! > -- > CipherTeKST > MCSE, CCNA > > > "Arnie Rowland" wrote: > >> It would help us better assist you if you could include table DDL, query >> strategy used so far, sample data in the form of INSERT statements, and >> an >> illustration of the desired results. (For help with that refer to: >> http://www.aspfaq.com/5006 ) >> >> >> The less 'set up' work we have to do, the more likely you are going to >> have >> folks tackle your problem and help you. Without this effort from you, we >> are >> just playing guessing games. >> >> One 'guess' is that you have "[Column Name]" preceding a ColumnName, >> e.g., >> [Column Name].ColumnName. >> >> -- >> Arnie Rowland, Ph.D. >> Westwood Consulting, Inc >> >> Most good judgment comes from experience. >> Most experience comes from bad judgment. >> - Anonymous >> >> >> "The Saint" <thesa***@discussions.microsoft.com> wrote in message >> news:56B18006-4A01-4CB0-8522-CB7DC506CA85@microsoft.com... >> >I am trying to join three different tables on common column names, with >> >a >> > Group by clause on the first table. This is the error I keep getting >> > >> > The column prefix "column name" does not match with a table name or >> > alias >> > name used in the query. >> > >> > Any help will be greatly appreciated! >> > -- >> > The Saint >> > MCP, MCDST, MCSA, CCNA >> >> >> |
|||||||||||||||||||||||