Re: ORDER BY relevance DESC query

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hey friend.

The problem is here:
( SELECT `reference`, `organization` FROM `ministry_profiles`...

In a subselect, you must select just one column. You are selecting two "reference" and "organization".

If you really need both, so you must do two subselects: one for "reference" and another for "organization".


Cheers!
Adriano Laranjeira.
SÃo Paulo - Brazil.
> > > > > > > > On Tue, 12 Apr 2011 04:00:15 -0400
"Ron Piggott" <ron.piggott@xxxxxxxxxxxxxxxxxx> wrote:
I am programming the search feature for a directory. I am trying to make the query display the results in order of relevance (Greatest to least). I thought I had to perform the query similar to a column being selected in order to sort the results by "relevance". What changes do I need to make to my query for it to work correctly?

The mySQL query is giving me the error message:
#1241 - Operand should contain 1 column(s)

The FULLTEXT index contains:
organization
address_line_1
address_line_2
city
province_state
postal_zip_code
country
telephone
toll_free
fax
email
website

Presently the mySQL query is:

SELECT `reference`, `organization` , ( SELECT `reference`, `organization` FROM `ministry_profiles` WHERE MATCH( `ministry_profiles`.`organization`, `ministry_profiles`.`address_line_1`, `ministry_profiles`.`address_line_2`, `ministry_profiles`.`city`, `ministry_profiles`.`province_state`, `ministry_profiles`.`postal_zip_code`, `ministry_profiles`.`country`, `ministry_profiles`.`telephone`, `ministry_profiles`.`toll_free`, `ministry_profiles`.`fax`, `ministry_profiles`.`email`, `ministry_profiles`.`website` )
AGAINST
('$search') AND `live` = 1 ) AS relevance FROM `ministry_profiles` WHERE MATCH( `ministry_profiles`.`organization`, `ministry_profiles`.`address_line_1`, `ministry_profiles`.`address_line_2`, `ministry_profiles`.`city`, `ministry_profiles`.`province_state`, `ministry_profiles`.`postal_zip_code`, `ministry_profiles`.`country`, `ministry_profiles`.`telephone`, `ministry_profiles`.`toll_free`, `ministry_profiles`.`fax`, `ministry_profiles`.`email`, `ministry_profiles`.`website` )
AGAINST
('$search')
AND `live` = 1
ORDER BY relevance DESC


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux