
September 14th, 2004, 12:12 PM
|
|
Registered User
|
|
Join Date: Sep 2004
Posts: 1
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
Search Query Returning Duplicate Records
Basically I want to search for a term (apple) and return the results. It's structured basically like a message board where people post a problem (incident), then we post notes attached to the problem. The following code works fine, however if apple comes up in 2 different "notes" within the same problem, the incident is returned twice. I would like for only one incident to be returned even if multiple notes within it contain "apple." Could anyone steer me in the right direction?
Code:
SELECT DISTINCT Incidents.Incident, IncidentNotes.Summary, IncidentNotes.user_id, (Locations.Location+' - '+Locations.Description) AS LocDisp, tbl_workorder_status.*
FROM ((Incidents INNER JOIN IncidentNotes ON Incidents.Incident = IncidentNotes.Incident) INNER JOIN Locations ON Incidents.LocationID = Locations.LocationID) INNER JOIN tbl_workorder_status ON Incidents.status = tbl_workorder_status.status_id
WHERE IncidentNotes.Description Like ('*apple*') OR IncidentNotes.Summary Like ('*apple*')
ORDER BY Incidents.Incident DESC
|