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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:06:19+00:00 2026-05-26T18:06:19+00:00

I’m making a website with specific posts that have tags created by the user.

  • 0

I’m making a website with specific posts that have tags created by the user. My database looks like this:

Qid              Tag
3                Happy
3                Sad
3                Funny
6                Happy
6                Delicious
8                Angry

What I want to do is to find related tags.

My plan is to enter a tag as the key (say Happy for example) and then come out Sad, Funny, and Delicious.

But I only want a max of say 5 or 6.

In the real database, there are tons more of these entries, but i don’t know how to choose between the top 5 or 6.

My questions are:

  1. How would i do the query properly to just come up with all related tags?
  2. How would i narrow my best search results to 5 or 6?
  3. Is there an even better way to do related tags that i haven’t thought of (e.g., dictionary)?

BTW, it’s in PHP so I can do post processing there, too.

  • 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-26T18:06:20+00:00Added an answer on May 26, 2026 at 6:06 pm

    To give a general answer to your question…

    1. You need to find the QID of the tag, then select all tags with that QID – this depends, of course, on how you store post metadata in your database

    2. If by ‘best search results’ you mean most-used tags, then you need to add another column to the table – something like frequency. Then, have that increase by one each time the tag is used. But, to find the top five based on that assumption, you would do something like:

      SELECT * FROM tag_table
      WHERE qid = 3            /* Where 3 is just an example                     */
      ORDER BY frequency DESC  /* so the most used are at the top of the results */
      LIMIT 5;                 /* select only the first five results             */
      
    3. I’m not sure what would be a better way, to be honest. Without any further information, it’s hard to know.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have some data like this: 1 2 3 4 5 9 2 6
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have a reasonable size flat file database of text documents mostly saved in
I have a bunch of posts stored in text files formatted in yaml/textile (from

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.