View Single Post
Old 05-25-2006, 08:31 AM   #2 (permalink)
Redline
PHP Student
 
Join Date: Oct 2004
Location: Forest Grove, OR
Posts: 151
Redline is on a distinguished road
Send a message via AIM to Redline Send a message via MSN to Redline
You're right, you want to JOIN your tables together into a virtual table to get all your data in one query. Here's how I would do it:

Code:
$query = "
SELECT developer_log.*, developer.* 
FROM developer_log LEFT JOIN developer 
USING (project)";
// Add WHERE developer.name = "name" at the end to restrict results 
// to only one particular developer. A good idea would be to add a 
// "developer_id" field to both the developer_log, and developer tables.
What this does is "join" the tables together into a virtual table which only lasts the duration of the the query. the USING (project) bit simply says that when the tables are joined together, use the "project" key to match rows from one table to the rows from the other. "WHERE developer_log.project = developer.project" would have the exact same effect, but use the "USING" command whenever the field names are the same. This helps keep your WHERE conditional statements a little less cluttered when you start making more complicated queries.
__________________
Current Project
Redline is offline   Reply With Quote