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'

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

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

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);
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.