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

You can join as many tables as you like in a single query...

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'

The above is just to illustrate - I'm no SQL expert.

-- Klaus.

-----Oprindelig meddelelse-----
Fra: HurricaneIndy <email protected> <HurricaneIndy <email protected>>
Til: phplib <email protected> <phplib <email protected>>
Dato: 14. maj 2001 14:41
Emne: [phplib] OT: Joining Tables

Hey all,
I want to create an admin page which shows a listing of all the users in the database. Problem is most of the columns in my users table are foreign keys going to another table. So the way my users table is setup right now, I can only get: userid,username and password. If I join another table in the query I can get what company they belong to. But there are about 5 more columnns I would like to get. How would I go about getting the rest and outputting it? I know that I can just create another query.. $result, $result2 and so on...but there must be a better way correct?

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