jaymc Posted February 26, 2007 Share Posted February 26, 2007 I have a table which contains usernames in a field called 'member' I have a query that will query that table and for each username in there it will then do another query However, some usernames may appear 10 times in the table, so they will have the exact same query executed 10 times.. How can I structure my very first query on the members table to only return a username once rather than every occurance I've been told possibly group could do this? FYI, there is 200,000 rows of usernames.. Quote Link to comment https://forums.phpfreaks.com/topic/40096-only-select-a-string-once-from-a-db/ Share on other sites More sharing options...
christo16 Posted February 26, 2007 Share Posted February 26, 2007 Would a "LIMIT 1" work? mysql_query("SELECT * FROM usernames WHERE name = '$variable' LIMIT 1" ) Quote Link to comment https://forums.phpfreaks.com/topic/40096-only-select-a-string-once-from-a-db/#findComment-194006 Share on other sites More sharing options...
jaymc Posted February 26, 2007 Author Share Posted February 26, 2007 No the query needs to put all the usernames into a variable and I fetch it with mysql_fetch_array having LIMIT 0,1 would only pick out 1 username from the table Quote Link to comment https://forums.phpfreaks.com/topic/40096-only-select-a-string-once-from-a-db/#findComment-194009 Share on other sites More sharing options...
btherl Posted February 26, 2007 Share Posted February 26, 2007 Is this what you're looking for? SELECT DISTINCT member FROM table Quote Link to comment https://forums.phpfreaks.com/topic/40096-only-select-a-string-once-from-a-db/#findComment-194029 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.