Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3302538
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T20:51:44+00:00 2026-05-17T20:51:44+00:00

Okay, here’s what I’m trying to do. I have a drupal table (term_data) in

  • 0

Okay, here’s what I’m trying to do. I have a drupal table (term_data) in mysql that lists tags and their ID numbers and a second table, (term_node) that shows the relationship between tags and the data the tags refer to. For example, if node 1 had 3 tags, “A”, “B” and “C”. term_data might look like this:

name tid
A    1
B    2
C    3

and term_node might look like this:

nid  tid
1    1
1    2
2    2
3    3
3    2

In this example, node 1 has been tagged with “A” and “B”, node 2 has been tagged with “A” and node 3 has been tagged with “B”, and “C”.

I need to write a query that, given a tag name, list for me all the OTHER tags that are ever used with that tag. In the above example, searching on “A” should return “A” and “B” because node 1 uses both, searching on “C” should return “B” and “C”, and searching on “B” should return “A”, “B” and “C”.

Any ideas? I got this far:

select distinct n.nid from term_node n INNER join term_data t where n.tid = t.tid and t.name=’A’;

Which gives me a list of every node that has been tagged with “A” – but I can’t figure out the next step.

Can anyone help me out?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T20:51:45+00:00Added an answer on May 17, 2026 at 8:51 pm

    Try:

    select distinct d2.name
    from term_data d1
    join term_node n1 on d1.tid = n1.tid
    join term_node n2 on n1.nid = n2.nid
    join term_data d2 on n2.tid = d2.tid
    where d1.name = 'A'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Okay, here's the scenario. I have a utility that processes tons of records, and
Okay here's the program I have typed up(stdio.h is included also): /* function main
Okay here is the scenario! I have a Person object which has an Address
Okay here is what I'm, trying to do I want to escape the period
Okay, so I'm making a table right now for Box Items. Now, a Box
Okay, we know that the following two lines are equivalent - (0 == i)
Okay here is a softball beginner WPF question. By default the background of the
Okay here's the damned thing: - (void)setMinimumNumberOfSides:(NSNumber *)newMinimumNumberOfSides { if (newMinimumNumberOfSides != minimumNumberOfSides) {
Okay here is a puzzle I come across a lot of times- Given a
Hey all. Okay here is the situation. I would like to be able to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.