You need to do a join on the tables, Simplest way is
Select * from gardens a, state b where a.state_id = b.id Assuming id in the state table is actually what your planning on joining on. Try to do it on the mysql command line before doing in code to make sure you actually have the data you need. -----Original Message----- From: jsf [mailto:[EMAIL PROTECTED] Sent: Wednesday, 23 February 2005 3:08 PM To: mysql@lists.mysql.com Subject: newbie question This may be more of a PHP question than a MySQL question but here goes: I have a small database with two tables in it. It's a database of Botanical Gardens in the US. Table 1 contains the botanical gardens and has 8 fields: (I'm abbreviating for brevity and clarity): id, name, address, town, state_id, zip, phone, url Table 2 contains the states referred to in the 'state_id' field and itself has 3 fields id, abbreviation, name So, 'id' in the 'state' table is linked to the 'gardens' table via that table's 'state_id' field. Now, in pulling data out of the database to display on a web page I have all of my connection stuff working and the query of 'select * from gardens' along with this php code: <td align="center"><?php echo $row_Recordset1['botgard_name']; ?></td> <td align="center"><?php echo $row_Recordset1['botgard_address']; ?></td> <td align="center"><?php echo $row_Recordset1['botgard_town']; ?></td> <td align="center"><?php echo $row_Recordset1['state_id']; ?></td> <td align="center"><?php echo $row_Recordset1['botgard_zip']; ?></td> <td align="center"><?php echo $row_Recordset1['botgard_phone']; ?></td> <td align="center"><?php echo $row_Recordset1['botgard_url']; ?></td> works fine, pulling records out of the 'gardens' table and displaying it on a web page, but, of course, I'm seeing the 'state_id' instead of either the 'state_abbreviation' or the 'state_name'. I am at a complete and total loss as to how to edit my code at this point so that, before displaying anything, i can grab either 'state_abbr' or 'state_name' from the states table, properly associated with the 'state_id' and display the actual state abbreviation or state name in my web page. I'm so close, yet so far. I know if I can be shown once how this works, I'll be able to apply the solution again in the future. Thanks in advance for any help with this. Sincerely, Joshua -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED] -- No virus found in this incoming message. Checked by AVG Anti-Virus. Version: 7.0.300 / Virus Database: 266.4.0 - Release Date: 22/02/2005 -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.300 / Virus Database: 266.4.0 - Release Date: 22/02/2005 -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]