|
database
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Inner member of Outer Join Clauseposition, but we still want to see the employye listed - so we use an outer join to show all employees even if they don't have a position. If they do have a position, we want to join that position to another table to get the position description. Here's the query: select c.*, d.* from (select a.emplid, a.name, isnull(b.position_nbr,'0') NBR from ps_personal_data a, ps_rptc_ee_posn b where a.emplid *= b.emplid) c , (select descr, position_nbr from ps_position_data) d where d.position_nbr = NBR this returns with this error: The table 'ps_rptc_ee_posn' is an inner member of an outer-join clause. This is not allowed if the table also participates in a regular join clause. Is there any way around this?? We need to run several queries similar to this, and it makes no sense that SQL won't do this. Untested, since there was no DDL to work from:
SELECT a.emplid, a.name, COALESCE(b.position_nbr,'0') AS nbr, d.descr, d.position_nbr FROM ps_personal_data a LEFT OUTER JOIN ps_rptc_ee_posn b ON a.emplid = b.emplid LEFT OUTER JOIN ps_position_data d ON COALESCE(b.position_nbr,'0') = d.position_nbr You might want to consider using the SQL-92 standard join syntax instead of the '*=' syntax that is deprecated my Microsoft. Show quote "LauraRB" <Laur***@discussions.microsoft.com> wrote in message news:B5173590-E9AC-4B3B-9AEC-05DF38CA5E17@microsoft.com... > I'm trying to run this query - essentially, an employee may not have a > position, but we still want to see the employye listed - so we use an outer > join to show all employees even if they don't have a position. If they do > have a position, we want to join that position to another table to get the > position description. Here's the query: > > select c.*, d.* from > (select a.emplid, a.name, isnull(b.position_nbr,'0') NBR > from ps_personal_data a, ps_rptc_ee_posn b > where a.emplid *= b.emplid) c , > (select descr, position_nbr from ps_position_data) d > where d.position_nbr = NBR > > this returns with this error: > > The table 'ps_rptc_ee_posn' is an inner member of an outer-join clause. This > is not allowed if the table also participates in a regular join clause. > > > Is there any way around this?? We need to run several queries similar to > this, and it makes no sense that SQL won't do this. |
|||||||||||||||||||||||