Re: Left Join with more than two tables......

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The left join works the same for two or more tables.
select * from table1
left join table2 on table1.id=table2.id
left join table3 on table1.id=table3.id
...

Just specify the table you want to join and what to use to join them.

On Tuesday, August 12, 2003, at 03:16 PM, Michael Cortes wrote:

I know that we can ......

select last_name,first_name, table2.school from table1 left join table2 on
school_id=bldg_id


Listing all students and giving the school name for all students, if they have
one. If not, it lists the kid anyway and leaves that field blank.


Anyhow, how about multiple tables? I can't find it with google.

I have :
table1 with the students
table2 with library PINs and an autoincrement id
table3 with a lunch status and an autoincrement id

I want to list all students (I will select just certain fields) but if they
have it, I want to list the PIN from table2 and the lunch status from table3.


I can do it as a join but then anystudent who doesn't cross-reference gets
left out. I need to list all students.


--
Brent Baisley
Systems Architect
Landover Associates, Inc.
Search & Advisory Services for Advanced Technology Environments
p: 212.759.6400/800.759.0577


-- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux