mysql - How to find same/mutual/common entries of two users? -
this question has answer here:
i want find pages 2 users (status = 1
) or dislike (status = 0
).
structure pages_likes
:
assume user id (uid
) 1
, i'm on page of user user id uid = 2
, want select page_id
entries have in common user.
how select or count amount of page_id
entries have in common?
i found out way it:
select distinct p.title_de, l.page_id (select page_id pages_likes uid in (2, 1) , status = 1) l left join pages p on l.page_id = p.id group l.page_id having count(l.page_id) > 1
i'm not sure if best way, because use query twice different where-conditions (changing status = 0
dislikes), seems work.
Comments
Post a Comment