Query 3 tables?

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
lair74
Forum Newbie
Posts: 1
Joined: Sun Dec 28, 2008 7:50 pm

Query 3 tables?

Post by lair74 »

Can anyone post an example on how I can connect 2 or 3 tables to display the data?

tableComp
compID
compName
compTypeID
empID

tableCompTypes
compTypeID
types

tableEmps
empID
empName

OR
boardType_tbl
boardTypeID
type

boardMembers_tbl
name
boardTypeID

Data in boardType_tbl
types = Executive Officers
Directors
Liaison
Interim Executive Director
Staff

Data in boardMembers_tbl
name = name 1 boardTypeID =1
name2 1
name3 1
name4 2
name5 3

I need to display the data in groups by boardTypeID to display the members
Right now I got all the board types being display with the member name, I need to group by the board types.
Directors
name1,name2,name3 ect..

Any help will be very appreciated.
Thanks.
cptnwinky
Forum Commoner
Posts: 84
Joined: Sat Dec 27, 2008 10:58 am
Location: Williamstown, MA

Re: Query 3 tables?

Post by cptnwinky »

I'm no good at understanding them but I think this is what joins are all about.

http://www.techonthenet.com/sql/joins.php
Andrewrun
Forum Newbie
Posts: 7
Joined: Fri Dec 26, 2008 12:46 pm

Re: Query 3 tables?

Post by Andrewrun »

Check out: http://sqlzoo.net/select_join

That has a lot of tutorials on using join statements.
Post Reply