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 9122285
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T06:03:59+00:00 2026-06-17T06:03:59+00:00

I actually don’t have any code yet to provide..but I can give you the

  • 0

I actually don’t have any code yet to provide..but I can give you the data I am trying to manipulate.

I am working with a set of tags/keywords. Keywords can be related to another via the ‘related_id’ column.

So my table looks like:

keyword_tbl:
keyword_id | keyword | related_id

For this example, lets imagine the table is populated with the following entries

Entry 1:
keyword_id : 1
keyword: Marathons
related_id: 0

Entry 2:
keyword_id : 2
keyword: Boston
related_id: 1

As you can see, this entry of Boston, is related to Marathons via the related_id

I am working on giving the user the ability to search. If they search for an individual term, thats easy and not the question. However, if they search for “Boston Marathon,” I now am having difficulty with the query.

SELECT * FROM keyword WHERE keyword LIKE "%boston%" OR keyword LIKE "%marathon%"

After this initial query, i’d like to compare the results, which would be the 2 entries I detailed above.

Id like to return only the term that is related to the other. In this case, Boston is the ‘lowest’ common denominator, and thus, I’d like to return it.

Imagine: Marathons -> Boston

Can this be done in a single query?

Thanks!

  • 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-06-17T06:04:01+00:00Added an answer on June 17, 2026 at 6:04 am

    I’m thinking something like this might do the trick:

    SELECT
      a.*
    FROM keyword a
    JOIN keyword b
    ON (a.related_id = b.keyword_id)
    WHERE (a.keyword LIKE "%boston%"
           OR a.keyword LIKE "%marathon%")
    AND (b.keyword LIKE "%boston%"
           OR b.keyword LIKE "%marathon%")
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Okay, I actually don't have code as of yet because i'm just picking out
I don't know if it's actually possible to do, but I have a text
I haven't actually done this yet, and maybe I don't need to, but it
I hate to give the question this heading but I actually don't know whats
I actually don't even know how to call this :P, but... I have one
Somehow my master and my origin/master branch have diverged. I actually don't want them
There are similar questions, but none answers what I really need. I actually don't
I don't know if variadic is actually the right word, but I'm talking about
I've got a queue (actually 3 different queues but I don't believe that will
I would like to solve the following problem using constraints but i actually don't

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.