Joe Yoder wrote:
> I asked this question earlier without the Jobs component. I now
understand how to handle that one with a join but haven't figured out
how to join a join. As before this code gives me a single record but I
need one for the case where there is no Typ2.
> TIA - Joe Yoder
>
> CREATE CURSOR Family (Id I)
> CREATE CURSOR Members (Parent I, Type C(1), Jcode C(1))
> CREATE CURSOR Jobs (Code C(1), Desc C(1))
>
> INSERT INTO Family (Id) VALUES (1)
> INSERT INTO Family (Id) VALUES (2)
> INSERT INTO Members (Parent, Type, Jcode) VALUES (1, 'a', '1')
> INSERT INTO Members (Parent, Type, Jcode) VALUES (1, 'b', '2')
> INSERT INTO Members (Parent, Type, Jcode) VALUES (2, 'a', '3')
> INSERT INTO Jobs (Code, Desc) VALUES ('1', 'A')
> INSERT INTO Jobs (Code, Desc) VALUES ('2', 'B')
> INSERT INTO Jobs (Code, Desc) VALUES ('3', 'C')
>
> SELECT Family.Id, M1.Type as Typ1, M2.Type as Typ2, J1.Desc as Job1,
J2.Desc as Job2;
> FROM Family, Members as M1, Members as M2, Jobs as J1, Jobs as J2;
> WHERE Family.Id = M1.Parent AND M1.Type = 'a';
> AND Family.Id = M2.Parent AND M2.Type = 'b';
> AND J1.code = M1.Jcode;
> AND J2.code = M2.Jcode
Joe,
You'll need to use a LEFT JOIN instead of the implied INNER JOIN syntax
you've used. Also, avoid headaches later on and don't use field names
like DESC, as that's a SQL keyword (for DESCENDING). Finally, I suggest
using the explicit JOIN syntax (INNER JOIN, LEFT JOIN, RIGHT JOIN, etc.)
for better clarity.
Cheers,
--Michael
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message:
http://leafe.com/archives/byMID/profox/[email protected]
** All postings, unless explicitly stated otherwise, are the opinions of the
author, and do not constitute legal or medical advice. This statement is added
to the messages for those lawyers who are too stupid to see the obvious.