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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T18:29:34+00:00 2026-05-30T18:29:34+00:00

Desperate for help on this, please help! I am running a fulltext search with

  • 0

Desperate for help on this, please help!

I am running a fulltext search with mysql. My data is held in two tables, so I have to run separate matches on each table and add the relevancy together as you can see in my MySQL statement.

The problem is that I am trying to get a COUNT for the total posts a question has in my post table. However this is only returned to me when the match is found in the question table, not if the match is found in the posts table? Any idea why?

Please tell me in more information is needed. Thanks,

SELECT questions. * , 
     posts.post, 
     COUNT(posts.post) -1 AS total_answers, 
     posts.votes, 
     posts.id AS post_id, 
     posts.created, 
     users.id AS user_id, 
     users.username, 
     users.rep, 
     MATCH (questions.title) AGAINST ( '{$keywords}') AS title_relevance,
     MATCH (posts.post) AGAINST ( '{$keywords}') AS post_relevance
FROM questions
     LEFT JOIN posts ON questions.id = posts.question_id
     LEFT JOIN users ON questions.user_id = users.id
WHERE MATCH (questions.title) AGAINST ( '{$keywords}')
    OR MATCH (posts.post) AGAINST ( '{$keywords}')
GROUP BY questions.id
ORDER BY (title_relevance + post_relevance) DESC

Found the answer.

SELECT questions. * , posts.post, posts.question_id AS QID, (

SELECT COUNT( posts.post ) 
FROM posts
WHERE question_id = QID
) AS total_answers, posts.votes, posts.id AS post_id, posts.created, users.id AS     user_id, users.username, users.rep, 
MATCH (
questions.title
)
AGAINST (
'humans'
) AS title_relevance, 
MATCH (
posts.post
)
AGAINST (
'humans'
) AS post_relevance
FROM questions
LEFT JOIN posts ON questions.id = posts.question_id
LEFT JOIN users ON questions.user_id = users.id
WHERE MATCH (
questions.title
)
AGAINST (
'humans'
)
OR MATCH (
posts.post
)
AGAINST (
'humans'
)
GROUP BY questions.id
ORDER BY (
title_relevance + post_relevance
) DESC 
LIMIT 0 , 30
  • 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-30T18:29:36+00:00Added an answer on May 30, 2026 at 6:29 pm

    Make sure that there is a full text index created on each table.

    MySQL can’t make a fulltext index across multiple tables. Therefore you should use an index on each table, and do a join to retrieve the rows that match your text.

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

Sidebar

Related Questions

Desperate, please help. Will work for food :) I want to be able to
I have been searching forever. Sorry, I am pretty desperate at this point so
First of all I am in DESPERATE need of help here PLEASE I will
I'm in desperate need of help and direction. Been trying to get this to
I'm new to this ExpandableListView and I desperately need your help please. I'm using
I am not familiar with this website but I am desperately seeking help with
I am in desperate need of help, I need to manage an application dependency
This has been driving me nuts for a few days. I am desperate for
Hey, I'm desperate right here. jQuery: $(.rotateme li a).click(function(){ var curid = $(this).attr('id'); $('#box'+curid).fadeIn('slow');
I desperately need to have my search form's default input text to change based

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.