RE: Sv: [phplib] OT: Joining Tables From: phplib (phplib <email protected>)
Date: 05/14/01

Klaus wrote:
>select u.username, p.firstname, c.company, h.smoker
>from users as u, persons as p, companies as c, health_info as h
>where u.userid = p.userid
> and u.userid = c.userid
> and u.userid = h.userid
> and u.userid = '39d0f11ad7b98ea0'

Actually, in this case it'd probably be better to do a left join.
Otherwise if someone doesn't have an entry in the company table
(or whatever) they won't show up in the list. something like:

select u.username, c.company from users as u left join company as
c on u.userid=c.userid

--Jesse

---------------------------------------------------------------------
To unsubscribe, e-mail: phplib-unsubscribe <email protected>
For additional commands, e-mail: phplib-help <email protected>