thinkphp left join 一定要写上left

本来应该查出3条出来的,怎么只查了一条呢?

    ->join("app_tool_ext_grant AS g ON g.tool_id = t.id")

 打印出sql语句看看:
  file_put_contents( 'd:\sq.txt', $app_tool_ext->getLastSql()) ;
 
 
SELECT t.* FROM app_tool_ext t INNER JOIN app_tool_ext_grant AS g ON g.tool_id = t.id INNER JOIN ...


原来是inner join了,添加上 left

  ->join("app_tool_ext_grant AS g ON g.tool_id = t.id", 'LEFT')

ok了

你可能感兴趣的:(sql,select,thinkphp)