thinkphp5.0 多表模糊查询 只出A表的模糊信息,B表有数据 但是出不来

thinkphp5.0 多表模糊查询 结果只能出来A表的模糊信息 B 表却丝毫不起作用?求助帮忙看下 下面的代码哪里有问题??

$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();//a.runstate=2  and ( a.shopname like '% $keyword %'  or b.goodsname like '%$keyword%')"

不是很清楚你的逻辑,感觉你的括号嵌套不正确,导致 b.goodsname like '%".$keyword."%' 没有作为单独的筛选条件

https://blog.csdn.net/meishi186/article/details/106399136

这个关联表是内联的,要看数据,虽然b表有对应的值但这个值没有关联到a表的数据( b.shopid = a.id没有匹配的),也是不会查询出来的