Skip to content

Instantly share code, notes, and snippets.

@DGaffney
Created May 13, 2011 20:15
Show Gist options
  • Select an option

  • Save DGaffney/971238 to your computer and use it in GitHub Desktop.

Select an option

Save DGaffney/971238 to your computer and use it in GitHub Desktop.
+----+------------+----------+--------+------------+------------+
| id | dataset_id | start_id | end_id | created_at | deleted_at |
+----+------------+----------+--------+------------+------------+
| 1 | 1 | 12 | 13348 | NULL | NULL |
| 2 | 1 | 107 | 13348 | NULL | NULL |
| 3 | 1 | 274 | 13348 | NULL | NULL |
| 4 | 1 | 324 | 13348 | NULL | NULL |
| 5 | 1 | 418 | 13348 | NULL | NULL |
| 6 | 1 | 422 | 13348 | NULL | NULL |
| 7 | 1 | 455 | 13348 | NULL | NULL |
| 8 | 1 | 456 | 13348 | NULL | NULL |
| 9 | 1 | 509 | 13348 | NULL | NULL |
| 10 | 1 | 544 | 13348 | NULL | NULL |
| 11 | 1 | 12 | 13349 | NULL | NULL |
| 12 | 1 | 107 | 13349 | NULL | NULL |
| 13 | 1 | 274 | 13349 | NULL | NULL |
| 14 | 1 | 324 | 13349 | NULL | NULL |
| 15 | 1 | 418 | 13349 | NULL | NULL |
| 16 | 1 | 422 | 13349 | NULL | NULL |
| 17 | 1 | 455 | 13350 | NULL | NULL |
| 18 | 1 | 456 | 13350 | NULL | NULL |
| 19 | 1 | 509 | 13350 | NULL | NULL |
| 20 | 1 | 544 | 13350 | NULL | NULL |
+----+------------+----------+--------+------------+------------+
#With data in a structure like this, how would I be able to find out the intersections of start_id from end_id? In other words, end_id of
#13348 and 13349 have 6 similar start_id rows (start_ids of 12,107,274,324,418,422), 13348 and 13350 have 4 (455,456,509,544), and 13349
#and 13350 have zero similar rows.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment