大橙子网站建设,新征程启航
为企业提供网站建设、域名注册、服务器等服务
语法
网站建设哪家好,找创新互联!专注于网页设计、网站建设、微信开发、小程序开发、集团企业网站建设等服务项目。为回馈新老客户创新互联还提供了青河免费建站欢迎大家使用!
join ( mixed join [, mixed $condition = null [, string $type = 'INNER']] )
示例
别名
Db::table('think_artist') ->alias('a') ->join('think_work w','a.id = w.artist_id') ->join('think_card c','a.card_id = c.id') ->select();
Db::table('think_artist') ->alias('a') ->join('__WORK__ w','a.id = w.artist_id') ->join('__CARD__ c','a.card_id = c.id') ->select();
$join = [ ['think_work w','a.id=w.artist_id'], ['think_card c','a.card_id=c.id'], ];Db::table('think_user')->alias('a')->join($join)->select();
全称
Db::table('think_user')->join('__WORK__','__ARTIST__.id = __WORK__.artist_id')->select();
right方式
Db::table('think_user')->alias('a')->join('word w','a.id = w.artist_id','RIGHT')->select();
表名是子查询
$subsql = Db::table('think_work') ->where(['status'=>1]) ->field('artist_id,count(id) count') ->group('artist_id') ->buildSql(); Db::table('think_user') ->alias('a') ->join([$subsql=> 'w'], 'a.artist_id = w.artist_id') ->select();