Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Limit rows

Status
Not open for further replies.

jokj

Programmer
Feb 4, 2004
1
SE
maybe this question is already answered but I'm in a kinda hurry.
I got a forum with a table looking like this

ID (int)
name (varchar)
email (varchar)
insert_date (int)
parent (int)
message(longtext)

How do I make the select query so that I only get one row that has a uniqe parent? The parent is the thread-id in the forum and I'm building a search-engine, and when I search in the forum I only want to get one instance of thread, I mean, if it finds the query several times in a single thread, I don't want it to list the thread more than one time anyway, as of now it lists a thread many times because it finds the query several times in it.

Another question:
I got a Q&A table where users have sent in their questions and someone have answered, the table looks like this:

id (int)
date_insert (int)
title (varchar)
message (longtext)
name (varchar)
answered (int)
answerid (int)

only those which have [answered]=1 will be shown cause I don't want to show a unanswered question, the answer is a new post in the same table but the [answered] is 2 there, just to mark it as a answer and not a question. The [answerid] points to the id where the answer is and it's NULL if it is a answer.

I'm making a searchfunktion to this to and I need to search in both question and answer but I only want to list one title per answer/question. As of now it searches in both answer and question and lists em both if it finds the query in both of them but I only want it to list it once. Lets say that I search for "what if", and "what if" is in both the question and answer it will list them both as to results, but I only want one result
ie.
If it finds it in only the question - one result
if it finds it in only the answer - one result
if it finds it in both the answer and the question - still only one result.
that's what I want.
How do I do that?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top