Inner join of same table with conditions

139 Views Asked by At

So my problem is as follow, I have a table in MySQL with a UserId column and an ObjectId column (its a many to many relationship), and what I would like is to have is a query that gives me the list of objects that user X and Y share. Not sure how to make the joins to make this happen.

1

There are 1 best solutions below

0
On

Use query something like below using self join

 Select columns from table t1 join table t2 on t1.objectid=t2.objectid where t1.userid=X and t2.userid=Y