MYSQL subquery error "Operand should atleast contain one column" -


i have error sql query;

mysql_query(" select * houses  pcode=(    select outcode,(sqrt((pow((`x` -$x),2)) + (pow((`y` -$y),2)))) `distance`     hwz_postcodes     `x` between $xnegexp , $xplusexp     , `y` between $ynegexp , $yplusexp     order `distance` )"); 

basically there 2 tables 1 table has list of houses corrosponding post code , other table list of post codes. query compares post code nearby postcodes, , shows nearby houses.

the subquery sucessfully finds nearest postcodes , lists them in order of distance. can put while loop , perform query within @ houses table, not efficient.

can suggest solution query, remembering initial subquery results need ordered distance, distance stipulated square root formula shown.

thanks in advance!!

perhaps want this...

 select h.*       , p.*    houses h    join hwz_postcodes p      on p.outcode = h.pcode   p.x between $xnegexp , $xplusexp      , p.y between $ynegexp , $yplusexp; 

Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -