联表查询


左连接

User::where(['u.level' => 8])
    ->alias('u')
    ->join('user_info ui', 'u.id = ui.uid')
    ->fields('u.id, u.nickname, u.avatar, ui.name, ui.age')
    ->select();

右连接

User::where(['u.level' => 8])
    ->alias('u')
    ->join('user_info ui', 'u.id = ui.uid', 'RIGHT')
    ->fields('u.id, u.nickname, u.avatar, ui.name, ui.age')
    ->select();

内连接

User::where(['u.level' => 8])
    ->alias('u')
    ->join('user_info ui', 'u.id = ui.uid', 'INNER')
    ->fields('u.id, u.nickname, u.avatar, ui.name, ui.age')
    ->select();