I am trying to find an error in a massive SQL statement (not mine) - I have cut a lot of it out to make it readable - even pared down it still throws the error
SELECT DISTINCT Profiles.ID
FROM
(select * from Profiles RIGHT JOIN FriendList ON (FriendList.Profile = 15237)
order by LastLoggedIn DESC ) as Profiles
This returns an error
Duplicate column name 'ID'
I have tested the the last part (select * from Profiles ... order by LastLoggedIn DESC) and it works fine by itself
I have tried to troubleshoot by changing column names in the DISTINCT section without any luck.
One solution I read was to remove the DISTINCT, but that didn't help.
I just can't see where the duplicate column error can be coming from. Could it be a database integrity problem?
Any help much appreciated.
Profilesand theFriendListtable in your innerSELECThave anIDcolumn?? So you would basically have two columns, both calledID- and you're selecting everything from thatJOIN- so whichIDare you referring to when you saySELECT DISTINCT Profiles.ID .....?!?!?