Generate pairs of rows that share a date.
Section: Self joins
Pair records from the same day
sql
sql
SELECT a.id, b.id, a.event_date
FROM events a
JOIN events b
ON a.event_date = b.event_date
AND a.id < b.id;Explanation
Useful for pairing or clash detection inside one table.
Learn the surrounding workflow
Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.
Related commands
Same sheet · prioritizing Self joins
Employee to manager self join
Resolve a manager relationship stored in the same table.
Find duplicate emails with self join
Compare rows in the same table using inequality to avoid mirrored duplicates.
Use self join for one-level hierarchy
Great for direct parent relationships like employee → manager.