Forum Moderators: open

Message Too Old, No Replies

query problem

         

steven420

6:38 pm on Jun 15, 2007 (gmt 0)

10+ Year Member



Hi, I am having problems getting this query to work:

SELECT MATCH (prod_name,
long_prod_desc)
AGAINST('$this->search')
FROM $table_name
WHERE DISTINCT MATCH(
prod_name,
long_prod_desc)
AGAINST('$this->search') as
score,
prod_name,
long_prod_desc
ORDER BY score DESC LIMIT $this->from, $max_results

When I run the query the results are from the first match but I want the results from the second match. The query needs to be reversed but I can't figure out how to do it.Please help.

Thanks,
Steven.

mcibor

10:56 am on Jun 16, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi Steven,

here [dev.mysql.com] you've got MATCH syntax.

So to select that you would need:

SELECT DISTINCT prod_name, long_prod_desc
FROM $table_name
WHERE MATCH(
prod_name,
long_prod_desc)
AGAINST('$this->search')
ORDER BY prod_name, long_prod_desc DESC LIMIT $this->from, $max_results

However I am not sure what you want to achieve here, the name "score" makes me unsure.

Regards
Michal

PS. Maybe tell us what you want to achieve, not how does your query look like.
For that we'll need part of your table layout, some data in it and what you want to achieve with explaination.