Drupal 6 querying multiple tables Having some trouble with the Drupal 6 query syntax. My query works fine on its own:

SELECT term_node.tid, term_data.name FROM term_node, term_data WHERE nid = 22640


Below is what I have when I convert it for use with drupal 6:

$currentTIDs = db_query("SELECT {term_node}.tid, {term_data}.name FROM {term_node}, {term_data} WHERE nid = 22640");

while ($cTids = db_fetch_object ($currentTIDs)) {
array_push($currentTIDsArray, $cTids);
}

drupal_set_message('&lt;pre&gt;' . print_r($currentTIDsArray, TRUE) . '&lt;/pre&gt;');


This results in an empty query / array? Any Ideas?
I think you need a proper inner join.

Tweaking your snippet to:

$currentTIDs = db_query("SELECT tn.tid, td.name 
                         FROM {term_node} tn 
                         INNER JOIN {term_data} td
                         ON tn.tid = td.tid 
                         WHERE tn.nid = 22640");

while ($cTids = db_fetch_object ($currentTIDs)) {
   array_push($currentTIDsArray, $cTids);
}

drupal_set_message('&lt;pre&gt;' . print_r($currentTIDsArray, TRUE) . '&lt;/pre&gt;');


I digress, but worth mentioning Drupal coding conventions on variable names etc.. can be found here: http://drupal.org/coding-standards#naming