Mysql: Ignoring Duplicate Columns
Posted: Mon Nov 03, 2008 4:57 pm
Here's what I'm working on:
Now, some rows in table 'pages' have the same 'title' (they have the same 'description' too, just a slightly different 'url'). I do not want to display rows that share the same 'title', just one will do. How should I go about doing this? Can I do it in the query? I should mention that it does not matter which row is chosen and which are ignored... just need one of them.
Thanks for the help.
Code: Select all
$keyword = "blah";
$query = "SELECT *, ( (1.3 * (MATCH(title) AGAINST ('$keyword' IN BOOLEAN MODE))) + (0.6 * (MATCH(url,description) AGAINST ('$keyword' IN BOOLEAN MODE))) ) AS relevance FROM pages WHERE ( MATCH(url,title,description) AGAINST ('$keyword' IN BOOLEAN MODE) ) HAVING relevance > 0 ORDER BY relevance DESC";
$result = mysql_query($query) or die(mysql_error());
while($row = mysql_fetch_array($result)){
$url = $row['url'];
$title = $row['title'];
echo "<a href=$url>$title</a><br>";
}
Thanks for the help.