dimanche 11 janvier 2015

SQL: select specific triads of users

Given a table of users:



User(id INT, username VARCHAR(30))


and directed relations between them:



Following(follower_id INT, followee_id INT)


I need a SELECT for all unique triads of users such as:



A follows B
B follows A
A follows C
C follows B


I am working with SQLite database and using Python. With a SELECT for above example at hand I will probably be quick to do all the rest of triads I am after. These are essentially all possible combinations of directed connections within a triad of users.


Aucun commentaire:

Enregistrer un commentaire