$res=db('shop_info')->alias("a")->join('shop_goods b', ' b.shopid = a.id ')->field("a.id,a.shopname,a.addres,a.shopcbd,a.categoryname,a.opentime,a.closetime,a.categorypath,a.phone as telephone,a.shoppic,a.notice,a.shopstory,a.shopicon,a.salemode,a.longitude as lng,a.latitude as lat,(2 * 6378.137 * ASIN(SQRT(POW( SIN( PI( ) * ( ".$params['longitude']."- a.longitude ) / 360 ), 2 ) + COS( PI( ) * ".$params['latitude']." / 180 ) * COS( a.latitude * PI( ) / 180 ) * POW( SIN( PI( ) * ( " .$params['latitude']. "-a.latitude ) / 360 ), 2 )))) AS distance,b.goodsname,b.id as goodsid,b.onlineprice,b.originalprice,b.goodscover")->where("a.runstate=2 and a.city='".$params['cityName']."' and ( (a.shopname like '%".$keyword."%') or (b.goodsname like '%".$keyword."%'))")->order('distance asc')->limit($start,$pageSize)->select();求助各位大佬看一下,上面的写法哪里需要优化,两个表联查,第二个表时长出不来结果,刷新四五次能有一次有结果,不知道为什么用出哪里了 最佳答案