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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Removing duplication

Status
Not open for further replies.

nawrioj

Programmer
Feb 14, 2005
22
US
I'm trying to do a site search which have 4 functionalities (exact phrase, allword match, any word match and near match). These 4 types of site search will select the same fields but different conditions.

Any ideas on how I can eliminate the duplication ? I will need to display all the result of the 4 different types of site search in one page. Obviously, I don't want to display the same item twice.

Any ideas on how to manipulate the result through SQL ?

Thanks,

nawrioj
 
Can you just do this:

Code:
SELECT c1, c2, c3
FROM t
WHERE <condition 1>
  OR <condition 2>
  OR <condition 3>
  OR <condition 4>

This won't return duplicates.

--James
 
Yeah, I think that SQL wont return any duplicates but you're combining all 4 condition all at once. I need to identify which item belongs to "exact phrase condition", "all word condition", "any-word condition", and "near match condition"
while not having duplication on the result

This is the challenge ^_^

Thanks,
nawrioj
 
OK, you could do:

Code:
SELECT
  CASE WHEN <condition 1> THEN 'Exact match'
    WHEN <condition 2> THEN 'All word'
    WHEN <condition 3> THEN 'Any word'
    WHEN <condition 4> THEN 'Near match'
  END AS Type,
  c1, c2, c3
FROM t
WHERE <condition 1>
  OR <condition 2>
  OR <condition 3>
  OR <condition 4>

--James
 
let me test this sql and give you my feedback.

thanks,
nawrioj
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top