Garayed.com  

Go Back   Garayed.com > mySQL
FAQ Members List Calendar Search Today's Posts Mark Forums Read


Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-25-2006, 11:03 PM
 
Posts: n/a
Default Re: left join limit 1


"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.


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 10:05 PM.




LinkBacks Enabled by vBSEO 3.0.0 © 2007, Crawlability, Inc.