I do not have a very advanced knowledge in complex queries in Mysql.
I have a system where a user can follow each other and stay on top of the news from him.
I have two tables: one for users and one that keeps the connection between two users.
Do I need a hint system of friends, example would be Facebook friends that you suggested.
I wanted to do something. For example I follow a particular user and this follows another user, but I do not follow that user he follows. We three are from the same town where Sao Paulo, I wanted to make a query that suggested that user I still do not follow, because he is a friend of a friend of mine and because he is in the same city as me.
My tables are:
tb_usuario
id | name | city
1 | Halan | Sao Paulo
2 | John | Sao Paulo
3 | Maria | Sao Paulo
tb_ligacao
id | user_id | id_usuario_seguido
1 | 1 | 2
2 | 2 | 3
Can someone help me?
It seems like you are trying to see who is a friend of a friend. To do this, with your code:
The code above will get all friends for the user with the ID of 1. To get all of their friends, you would loop through and run the same code but change the ID to the variable of the loop.