Reputation: 1282
Table questions has the question id and title. Table posts has the id, question_id, post.
Is it possible to search for a field in a table using FULLTEXT indexing, and based on the rows value of the question_id field for example, perform a count of posts which have that question id which is being retrieved by sql. JOINS isnt helping me at the moment i'm afraid.
I have discovered the answer, you can select the id AS RESULT_ID and then perform another query with that answer! Thanks for your help, everyone!
Upvotes: 1
Views: 95
Reputation: 16677
first join things up.
select q.question_id, q.title
from question q, post p
where q.question_id = p.question_id
then filter down to the posts you want
select q.question_id, q.title
from question q, post p
where q.question_id = p.question_id
and p.post like '%SEARCHTERM%'
(or full text or whatever)
then count up
select q.question_id, q.title, count( post_id )
from question q, post p
where q.question_id = p.question_id
and p.post like '%SEARCHTERM%'
group by q.question_id, q.title
Upvotes: 1