语法
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();
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。