multi-table select?
| From: | Kirk Babb | Date: | Wed, 14 Jan 2004 22:41:10 +0000 |
| Subject: | multi-table select? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-174592@lists.php.net to get a copy of this message | ||
I'm looking for a good way to do the following:
I have two tables, one named teams and one named divisions.
Divisions relates divisionID to the name of the division
(division_name). In teams I have the divisionID stored
along with the team_name. [BG info: teams can be relegated
or promoted so it's easier for me to store the divID in
the teams table] I'd like to populate a drop down menu with
the team_name and division_name and was wondering if I can
do some kind of select statement that will get all the info
at once with the following details on the two tables:
mysql> select * from teams;
+--------+-----------+---------+------------+------+------------+-----+------+-----+-----------+---------------+
| teamID | team_name | coachID | divisionID | paid | pmnt_notes | win | loss | tie | goals_for |
goals_against |
+--------+-----------+---------+------------+------+------------+-----+------+-----+-----------+---------------+
| 1 | Metro | 0 | 1 | n | NULL | 0 | 0 | 0 | 0 |
0 |
+--------+-----------+---------+------------+------+------------+-----+------+-----+-----------+---------------+
1 row in set (0.00 sec)
mysql> select * from divisions;
+------------+------------------+
| divisionID | division_name |
+------------+------------------+
| 1 | Premier |
| 2 | Classic |
| 3 | Recreational 7v7 |
+------------+------------------+
3 rows in set (0.00 sec)
Thanks in advance!
Kirk