This query started initially with the adminblock module but also qualifies (I think) as a general support query.
What would like to do is figure out how to pull in data from three seperate MySQL tables that are related as shown below:
feedback.nid <---> node.nid / node.uid <---> users.uid <--->
The reason I want to do this is to display data from the feedback table, namely the contents of a field called "field_feedback_value" (yes, it's a CCK content type).
The way that I can see to do this would be to create a JOIN between the three tables. The code with which I originally began is, admittedly, from the adminblock module and looks like this.
$result2 = db_query_range('SELECT n.nid, n.title, n.changed, u.name, u.uid
FROM {node} n
INNER JOIN {users} u ON n.uid = u.uid
WHERE n.moderate = 1
ORDER BY n.changed DESC', 0, $nlimit);
$node_count = db_num_rows($result2);
$node_count_display = $node_count > $nlimit ? ' ('. $node_count .')' : '';
$items2 = array();
while ($node = db_fetch_object($result2)) {
$items2[] = 'Left by <b>' . check_plain($node->title) .'</b> on '. format_date($node->changed, 'short') .' - ' .' '. l(t('edit'), 'node/'. $node->nid .'/edit') .' | '. l(t('delete'), 'node/'. $node->nid .'/delete');
}
I would like to show the contents of the "field_feedback_value" in with the others on that last line which I imagine to be pretty straightforward once I have the join sorted.