![]() |
| |||
| "Bill Karwin" <bill@karwin.com> wrote in message news:e045b2017cl@enews2.newsguy.com... > <a> wrote in message news:cfmdnebNfKkX_LjZRVn-hg@comcast.com... >> Thank your for your reply. Let me clarify my work a bit. I have 3 >> tables. >> >> Company: company_id, company_name >> Person: person_id, company_id, person_name >> Location: location_id, company_id, location_name >> >> sometimes there is no person or location entry and sometimes tehre are >> person/lcoation entries per company. >> >> I use a "SELECT DISTINCT company.company_name, person._person_name, >> location.location_name >> LEFT JOIN person ON company.company_id = person.company_id >> LEFT JOIN location ON company.company_id = location .company_id >> ORDER BY company.compay_name" >> >> This gives me all the data I want, however it gives me too much, when >> there are two entries under person, or location w/ the same company_id. >> For my query, i just want to know, one person and location entry per >> company, basically, only row per company entry. >> >> Does your example work in this case? > > Probably the solution I gave is applicable. > > But you must specify which one person and which one company do you want to > display. > You mentioned "first instance," but how do you measure that? Which one is > "first?" > Alphabetically by person_name/location_name? The one with most matching > entries? Numerically by person_id/location_id? It doesn't matter which one. I'm thinking if you didn't specify, it would pick the first one entered. |
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
| |