Mysql query to find all rows that have the same values as another row

前端 未结 4 679
后悔当初
后悔当初 2020-12-11 06:03

My database contains rows that generally look like:

PersonItem
__________
id
personId
itemId

╔════╦══════════╦════════╗
║ ID ║ PERSONID ║ ITEMID ║
╠════╬═══         


        
4条回答
  •  既然无缘
    2020-12-11 06:38

    Something like this should do the trick:

    SELECT P1.*
    FROM PersonItem P1
    INNER JOIN PersonItem P2 ON P2.ID <> P1.ID
    AND P2.PersonId = P1.PersonId
    AND P2.ItemId =   P1.ItemId
    

提交回复
热议问题