mardi 18 août 2015

MYSQL - Randomly Selecting a row where two users are not following each other?

I am building an app that aims to show a user a randomly selected user from a list that he/she may like to follow where they are not following each other already.

I have 2 tables one table has a list of users and the second table has 2 columns that show a "following" relationship.

Table 1 user - user_id, instagram_id, join_date

Table 2 users_follow - instagram_id_1, instagram_id_2

I was just wondering if anyone could point me in the right direction on how to create the join and select a random row where the 2 users are not following each other? I have tried a left join but without any luck so far.

Thanks for the help.




Aucun commentaire:

Enregistrer un commentaire