ORDER BY relevance DESC query
am 12.04.2011 10:00:15 von ron.piggott
------=_NextPart_000_013C_01CBF8C6.21266AD0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
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` ,=20
( SELECT `reference`, `organization` FROM `ministry_profiles`=20
WHERE
MATCH( `ministry_profiles`.`organization`,=20
`ministry_profiles`.`address_line_1`, =
`ministry_profiles`.`address_line_2`,=20
`ministry_profiles`.`city`, `ministry_profiles`.`province_state`,=20
`ministry_profiles`.`postal_zip_code`, `ministry_profiles`.`country`,=20
`ministry_profiles`.`telephone`, `ministry_profiles`.`toll_free`,=20
`ministry_profiles`.`fax`, `ministry_profiles`.`email`,=20
`ministry_profiles`.`website` )
AGAINST
('$search')=20
AND `live` =3D 1
) AS relevance=20
FROM `ministry_profiles`=20
WHERE=20
MATCH( `ministry_profiles`.`organization`,=20
`ministry_profiles`.`address_line_1`, =
`ministry_profiles`.`address_line_2`,=20
`ministry_profiles`.`city`, `ministry_profiles`.`province_state`,=20
`ministry_profiles`.`postal_zip_code`, `ministry_profiles`.`country`,=20
`ministry_profiles`.`telephone`, `ministry_profiles`.`toll_free`,=20
`ministry_profiles`.`fax`, `ministry_profiles`.`email`,=20
`ministry_profiles`.`website` )
AGAINST
('$search')
AND `live` =3D 1
ORDER BY relevance DESC
------=_NextPart_000_013C_01CBF8C6.21266AD0--
Re: ORDER BY relevance DESC query
am 12.04.2011 14:40:09 von Adriano Rodrigo Guerreiro Laranjeira
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" 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