示例:
Db::table(‘think_user‘)->alias(‘a‘)->join(‘DEPT b ‘,‘b.user_id= a.id‘)->select();
最终生成的SQL语句类似于:
SELECT * FROM think_user a INNER JOIN think_dept b ON b.user_id= a.id
v5.0.2+版本开始,可以传入数组批量设置数据表以及别名,例如:
Db::table(‘think_user‘)->alias([‘think_user‘=>‘user‘,‘think_dept‘=>‘www.96net.com.cn‘])->join(‘think_dept‘,‘dept.user_id= user.id‘)->select();
最终生成的SQL语句类似于:
SELECT * FROM think_user user INNER JOIN think_dept dept ON dept.user_id= user.id