i have mysql table:
create table person (id int(6) auto_increment primary key,name varchar(30) not null,age int(4) not null); i run these inserts: insert person values(null, 'one', 42); insert person values(null, 'two', 49); insert person values(null, 'three', 16);
running:
select avg(age) person; gives me "35.6"
i index these table in sphinx. want run more or less same query in sphinx 1 run in mysql. command line issue command:
select avg(age) person_idx; fine. here "35.6".
now problem. need run query php. im using sphinxapi.php script comes sphinx-release. had @ docs , googled lot. cannot find way run these kind of functions (avg, sum etc) php. there way this?
in php have code:
require('sphinxapi.php'); $client = new sphinxclient(); $res = $client->query('', 'person_idx'); where put "select avg(age)" part of sql-query? sphinxapi.php has methods can call. cannot see way decide select.
add before query() call
$client->setselect("avg(age) avg_age"); setselect equivalent 'select ...' part of sphinxql. in general need use as function use.
Comments
Post a Comment