> > select people.id, > > people.first, > > people.last, > > home.phone as home, > > cell.phone as cell, > > work.phone as work, > > fax .phone as fax > > from people > > left join phones as home (people.id = home.id) > > left join phones as work (people.id = work.id) > > left join phones as cell (people.id = cell.id) > > left join phones as fax (people.id = fax .id); > > This does exactly what I want, with the changes: > > ...from people > left join phones as home ON people.id=home.id ... > > etc. > > I'm all ears for better ideas :-) >
Shouldn't this query be checking the type of the phone records? I think you need something like the following query to get the correct type of phone number in each column. select people.id, people.first, people.last, home.phone as home, cell.phone as cell, work.phone as work, fax .phone as fax from people left join phones as home on people.id = home.id and home.type = 'home' left join phones as work on people.id = work.id and work.type = 'work' left join phones as cell on people.id = cell.id and cell.type = 'cell' left join phones as fax on people.id = fax .id and fax.type = 'fax'; It seems to me there should be a better way though. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]