Your question is Mutual Follows Query. Start with the requirements and the one table on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
I have a table with follower and followee (where the follower follows the followee). How do you return a table of mutual follows?
Return each mutual relationship once, even though the source contains two directional rows. Ignore incomplete rows where either user ID is NULL.
follower_id and followee_id.follower_id, and the higher ID in followee_id.follower_id, then followee_id ascending.| Column | Type | Description |
|---|---|---|
| relationship_idPK | INT | Unique relationship record identifier |
| follower_id | INT | User who follows another user |
| followee_id | INT | User being followed |