Community Documentation

List all related terms of a term

Last updated April 26, 2011. Created by Jody Lynn on April 22, 2008.
Edited by MGParisi, faux_at. Log in to edit this page.

To find all related terms of a taxonomy term use this SQL code:

SELECT tid, name
FROM term_relation
INNER JOIN term_data
  ON (tid1 = tid OR tid2 = tid)
WHERE (tid1 = %d OR tid2 = %d)
  AND tid != %d;

Replace %d to the tid (ID of taxonomy term) of which you want to find the related terms.

Page status

About this page

Drupal version
Drupal 6.x

Archive

Drupal’s online documentation is © 2000-2012 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0. PHP code is distributed under the GNU General Public License.
nobody click here