Answer the question
In order to leave comments, you need to log in
Output Laravel + MySql matches?
How to display matches for the user -user_i = 1. You need to display users who were liked by user 1 and those users who liked this user.
For example, user 12 matches the condition, but I don’t know how to display it
$users = DB::table('likes')
->leftJoin('users','users.id','=','likes.like_user')
->leftJoin('user_attributes','user_attributes.user_id','=','likes.like_user')
->select('user_attributes.fullname','user_attributes.avatar','user_attributes.country','user_attributes.city','user_attributes.age',
'users.name','users.id','likes.created_at')
->where('likes.like_user','=', 'likes.user_id')
->where('likes.user_id','=', Auth::user()->id)
->paginate(15);
Answer the question
In order to leave comments, you need to log in
SELECT
likes_mutual.user_id
FROM
likes,
likes AS likes_mutual
WHERE
likes.user_id = likes_mutual.like_user
AND likes_mutual.user_id = likes.like_user
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question