Tuesday, March 7, 2017

double join sql same table

i have a table "payments" which contains the following: id client_id user_id and ofcourse for the payments.

i have another table users id firstname middlename lastname function (client or admin)

im joining users with the following sql query

$payments = Payment::findpayments()
    ->select('users.firstname', 'users.middlename', 'users.lastname', 'payments.*')
    ->join('users','payments.client_id', '=', 'users.id')
    ->where('payments.id', '=', $id)
    ->get();

now im getting the firstname etc from the client but i need to get the firstname middlename lastname twice for the client and admin does sombody have any idea how to double join the same table?



via Kevin

Advertisement