View Full Version : how to hide duplicate search results?
01-14-2007, 06:23 AM
i have a PHP script directory with an MYSQL database and it has some duplicate records.
the directory has a search functionality and duplicate results are showing up in the search results.
i would like to hide these duplicate results ( but dont want to delete them ).
all the records have a 'unique item' and i would like to filter the results using this 'unique item' ( so that a record with the same 'unique item' should not appear more than once )
please inform me how to filter my search results to avoid duplicates.
i am new to PHP and MYSQL. please inform me the possible code.
01-14-2007, 03:31 PM
you filter the results by not getting them in your sql statement in the first place.
please show some sample rows from your table as well as the output you would like to see from those rows and then show the sql query you are currently using.
01-14-2007, 09:19 PM
From an email from the OP I will post their additional info here for all to see.
the table is:
id int(11) NOT NULL auto_increment,
poll_id int(11) NOT NULL default '0',
link_count int(11) default '0',
popularityrank int(7) default '0',
destination varchar(12) NOT NULL default '',
title varchar(70) default NULL,
category varchar(100) default NULL,
PRIMARY KEY (id),
KEY category (category)
there are some rows with the same 'destination', 'title', 'description', but with different
id, poll_id, popularityrank etc...
i would like to ensure that no row with the same 'destination' should repeat in the search results.
and order the results by popularity rank.
the query is:
$sth = mysql_query("SELECT * FROM cb_urls WHERE category='".addSlashes(strtolower($keywords))."' OR title LIKE '%".addSlashes(strtolower($keywords))."%' or description LIKE '%".addSlashes(strtolower($keywords))."%' GROUP BY popularityrank LIMIT $mdf_startbound, $perpage");
01-14-2007, 09:21 PM
that shows your table but you also need to show some rows in the table and the output you want.
Show us where you have multiple destinations that are the same and then show us what row you want from those duplicates and explain the logic behind choosing that row and not one of the other rows with the same destination.
01-15-2007, 05:25 AM
thanks for your reply,
the example page is here:
destination field is hidden.
some rows have same destination, title, description but have different id, poll_id, popularityrank etc.
i would like to ensure that no row with the same destination or title or description repeat in the results.
can i make a query like this:
$sth = mysql_query("SELECT * FROM cb_urls WHERE destination != destination, category='".addSlashes(strtolower($keywords))."' OR title LIKE '%".addSlashes(strtolower($keywords))."%' OR keywd LIKE '%".addSlashes(strtolower($keywords))."%' or description LIKE '%".addSlashes(strtolower($keywords))."%' GROUP BY popularityrank LIMIT $mdf_startbound, $perpage");
thank you very much.
( yesterday i posted a pm with the reply because, i could not make a reply in the forum. even after waiting for a longtime, the hoverglass icon appeared without posting the reply. )
01-15-2007, 06:29 PM
so do you think you could actually post some sample rows here, (not some obscure link that we are supposed to figure out what we are looking at), and within those four or five rows contain duplicate information that you want to weed out, and then show us of those four or five rows, which one you want as the only result returned and why?
here is an example:
black cow 1
black cow 2
black turtle 3
black cow 4
I want the black turtle returned because it is the only turtle, and I wante black cow 1 returned because it has the lowest numeric value of the three cows.
If you can do something like that it will most likely ensure that you can get assistance with your problem.
As for the posting problem, I'd say to hit stop and try to reload a web page when that happens. :)
Powered by vBulletin® Version 4.2.2 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.