我们如何在 laravel 中使用自连接

how can we use self join in laravel

SELECT name, email, users.password
FROM users
INNER JOIN(
SELECT password
FROM users
GROUP BY password
HAVING COUNT(password) >1
)temp ON users.password= temp.password
where email = 'Excep@yesbus.com';

转换此 laravel 查询构建,我尝试了这种方式,但发现错误 base view not found

User::select('user_id, name, type, email, username, password')
                        ->join('temp', 'users.password', '=', 'temp.password')
                        ->groupBy('password')   
                        ->having('password', '>',1)
                        ->where('email', Input::get('username'))
                        ->get();
                    tried this does not work can anyone please suggest how we can do this thanks in advance

试试这个方法可能对你有帮助

$email = Input::get('username');

$users = DB::select( DB::raw("SELECT name, email, username, users.password FROM users INNER JOIN( SELECT password FROM users GROUP BY password HAVING COUNT(password) >1 )temp ON users.password= temp.password where email = '$email'") );