
Originally Posted by
guido2004
Why do you have the double entries? 1-5 and 5-1, 5-18 and 18-5?
simple answer: for optimum query performance
it is the difference between this --
Code:
FROM friend AS f1
INNER
JOIN friend AS f2
ON f2.friend_id = f1.id
and this --
Code:
FROM friend AS f1
INNER
JOIN friend AS f2
ON f2.friend_id = f1.id
OR f2.id = f1.friend_id
you already know which query is going to be faster, don't you 
the second query is often done as a UNION because in a single SELECT, mysql can't optimize it at all
Bookmarks