This is a basic table join:

select * from teams, divisions where teams.divisionID = divisions.divisionID



> -----Original Message-----
> From: Kirk Babb [mailto:[EMAIL PROTECTED]
> Sent: Thursday, 15 January 2004 9:41 AM
> To: [EMAIL PROTECTED]
> Subject: [PHP] multi-table select?
> 
> 
> 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
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> __________ Information from NOD32 1.594 (20040107) __________
> 
> This message was checked by NOD32 for Exchange e-mail monitor.
> http://www.nod32.com
> 
> 
> 
> 

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

Reply via email to