sw0o0sh Posted July 1, 2010 Share Posted July 1, 2010 I have a table called RSCD_TRAPS (it's for a game). The columns are as follows: id, user, time, ip, details I'm trying to do this query, (in combination with PHP): SELECT DISTINCT(user),id,time,details FROM rscd_traps However, it still will call non-distinct results for user. What am I doing wrong? I'm trying to basically fetch DISTINCT(user), and the corresponding columns that go along with it, however it ends up fetching the entire thing. Is there anyway to do this in 1 query? Quote Link to comment https://forums.phpfreaks.com/topic/206363-problem-with-distinct-and-multiple-columns/ Share on other sites More sharing options...
Mchl Posted July 1, 2010 Share Posted July 1, 2010 DISTINCT is not a function. It's a query modifier, that tells MySQL to return only distinct rows (always taking all columns into consideration). Quote Link to comment https://forums.phpfreaks.com/topic/206363-problem-with-distinct-and-multiple-columns/#findComment-1079554 Share on other sites More sharing options...
kickstart Posted July 1, 2010 Share Posted July 1, 2010 Hi Further to the above, is user unique on that table? If so then you do not need any way to pull a distinct row, if now then how do you want MySQL to determine the row to retrieve the other fields from? All the best Keith Quote Link to comment https://forums.phpfreaks.com/topic/206363-problem-with-distinct-and-multiple-columns/#findComment-1079601 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.