basicalli, i have a table: friends [id, fromid, toid]
[fromid] and [toid] represents the id of the user, fromid is who asked, and toid who acepted.
I consider two users ‘friends’ where ther is to items in friends table for each.
example: user 1 is friend of user 2 when i have:
in table friends:[id,1,2],[id,2,1],….
Im trying with this query and as i said in title gets me the ‘friens’, but two times :S
$sqlQueryCat5 = mysql_query("SELECT friends.*,usuarios.alias AS nombre_amigo FROM friends LEFT JOIN usuarios ON friends.toid=usuarios.id AND friends.fromid='$this->id' ORDER BY id");
I don’t know why.. and you?
thank you
It looks like you have another query that you are not showing here.
This query on its own only shows friends once, because
friends.fromid='$this->id'meansfromidcan only be the id asked.If your table ALWAYS contains [1,2] and [2,1] (both), then you only need to query one side to get the other.