Jump to content

Mysql: Ignoring Duplicate Columns


katlis

Recommended Posts

Here's what I'm working on:

 

$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>";
}

 

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?

 

Thanks for the help.

 

Edit: I should mention that it does not matter which row is chosen and which are ignored... just need one of them.

 

Link to comment
https://forums.phpfreaks.com/topic/131271-mysql-ignoring-duplicate-columns/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.