0

I'm having trouble with a query.
Here's my code.

----------------------------------------------

"SELECT *
FROM listings
WHERE MATCH(title)
AGAINST('ipod' IN BOOLEAN MODE)
ORDER
BY relevance DESC"

----------------------------------------------

And I get this error:

Unknown column 'relevance' in 'order clause'

2
Contributors
3
Replies
4
Views
4 Years
Discussion Span
Last Post by KyleMorgan49
0

Relevance isn't a command, you have to declare it:

SELECT *
FROM listings
WHERE MATCH(title)
AGAINST('ipod' IN BOOLEAN MODE)
AS relevance
ORDER
BY relevance DESC
0

SELECT *
FROM listings
WHERE MATCH(title)
AGAINST('ipod' IN BOOLEAN MODE)
AS relevance
ORDER
BY relevance DESC

Thanks! But with that I get:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AS relevance ORDER BY relevance DESC' at line 5

0

This is more of my code (not including the connector)

$key = $_POST['search_term'];

$query = "SELECT *
FROM listings
WHERE MATCH(title)
AGAINST('$key' IN BOOLEAN MODE)
AS relevance
ORDER
BY relevance DESC";

$result = mysql_query($query) or die("Internal Server Error: " . mysql_error());

while($row = mysql_fetch_assoc($result)) {
    ?><div class='span12'>
        <h4><?PHP echo $row['title']; ?></h4>
        <p><?PHP echo $row['description']; ?></p>
        <p><a class='btn-small' href='#'>View details &raquo;</a></p>
    </div><hr><!--/span--><?PHP echo "\n";
}

//Free resultset
mysql_free_result($result);

//Closing connection
mysql_close($link);
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.