"Select TOP 5 friends.userid,friends.AmigoNome,friends.AmigoCod, fotos.* from friends,fotos where friends.userid = "&IDDoUsuario&" AND fotos.por = friends.AmigoCod"
SQL que da erro, mas é o que eu queria.. por que não quero que repita o "AmigoCod" isso, é se tiver duas pessoas diferentes, mas estas duas pessoas aparecam na lista umas 50 vezes... so tem que me gerar dois resultados.. tentei assim
"Select TOP 5 friends.userid,friends.AmigoNome,friends.AmigoCod, fotos.* from friends,fotos where friends.userid = "&IDDoUsuario&" AND fotos.por = friends.AmigoCod GROUP BY friends.AmigoCod"
e da o seguinte erro:
Microsoft OLE DB Provider for SQL Server (0x80040E14)
Column 'friends.userid' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.
Alguém sabe por que? como arrumo...