revert the SQL query changed in 597896f

fetchPortsAndLinks: the SQL query optimization performed in 597896f
commit, was incorrect. It did not respect the fact that there could be
such rows that X.porta = Y.portb. But this could happen since the port
may be linked multiple times now.

So reverting the slow but correct query.