Subject | Re: Multiple Joins to the same field |
---|---|
Author | ra8009 |
Post date | 2005-11-02T03:32:06Z |
Thanks Helen. You're right that the lack of normalization is what
created this problem in the first place. It was an issue I inherited.
created this problem in the first place. It was an issue I inherited.
>
> Use multiple aliases for the PhoneNumberType table.
>
> select
> cust.somefield,
> cust...,
> pnt1.description as desc1, cust.PN1,
> pnt2.description as desc2, cust.PN2,
> pnt3.description as desc3, cust.PN3,
> pnt4.description as desc4, cust.PN4
> from customer cust
> join PhoneNumberType pnt1 on pnt1.ID=cust.phone_type_ID1
> join PhoneNumberType pnt2 on pnt2.ID=cust.phone_type_ID2
> join PhoneNumberType pnt3 on pnt3.ID=cust.phone_type_ID3
> join PhoneNumberType pnt4 on pnt4.ID=cust.phone_type_ID4
>
> It seems your customer table is crying out for normalization!!
>
> ./heLen
>