// $tid = db_query_range('SELECT t.tid FROM {taxonomy_index} ti INNER JOIN {taxonomy_term_data} t ON ti.tid = t.tid INNER JOIN {taxonomy_vocabulary} v ON t.vid = v.vid WHERE ti.nid = :nid ORDER BY v.weight, t.weight, t.name', 0, 1, array(':nid' => $node->nid))->fetchField();