You are here: Re: Need help with this select statement « MsSQL Server « IT news, forums, messages
Re: Need help with this select statement

Posted by Erland Sommarskog on 10/02/82 11:51

rhaazy (rhaazy@gmail.com) writes:
> When I run this query:
> select Employeeid, tblEmployee.EmpID, OrgNode
> from tblEmployee JOIN tblEmployeeOrgNode a
> on tblEmployee.EmpId = a.EmpID,
> tblOrgSystemNode JOIN tblEmployeeOrgNode b
> on tblOrgSystemNode.OrgNOdeId = b.OrgNodeID
>...
>
> This is what I am trying to get:
> Name ID Location
> rh 1 Mano
> rm 2 Huso
> rd 3 Oso

It's good to have the table, but with out sample data and an explanation
of the table, it's difficult to make much useful out of it. It had also
help if you had included definitions of primary keys and foreign keys.

But I note your query includs a cross join with tblOrgSystemNode. This
looks suspicious. Maybe that is an error. So as a complete guess

select E.Employeeid, E.EmpID, S.OrgNode
from tblEmployee E
JOIN tblEmployeeOrgNode EON on E.EmpId = EON.EmpID,
JOIN tblOrgSystemNode S ON S.OrgNOdeId = EON.OrgNodeID

If this does not meet your requirements, please supply sample data
(as INSERT statements) and briefly explain the business rules.

--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация