jaymc Posted November 28, 2006 Share Posted November 28, 2006 I have a username field in my database that is set to binary, so basically, Jamie is not the same as jamieSo in their their may be the following usernamesJamiejamieJaMiEWhat I want to do is query the database and have it return all the duplicate entries ignoring the rule of character binaryAny ideas Quote Link to comment Share on other sites More sharing options...
btherl Posted November 29, 2006 Share Posted November 29, 2006 You might be able to use [code=php:0]SELECT * FROM users WHERE username ILIKE 'jamie'[/code]ILIKE is case-insensitive.Another option is to compare [code=php:0]WHERE LOWER(username) = 'jamie'[/code] Quote Link to comment Share on other sites More sharing options...
jaymc Posted November 29, 2006 Author Share Posted November 29, 2006 HmmmBasically, I'll explain in a bit more detail what I want to achieveI have a 100,000 row member database, so basically 100,000 usernamesI want to change the username field to ASCI so usernames are not case sensitiveI cant do that until I remove/rename duplicate usernamesI tried dumping every username from a loop into an array then for each username see if it already exists in the array, if it did then I know its a duplicate entryBut because their is 100,000 rows the script takes a while and dies at 60 seconds for max execution time Quote Link to comment Share on other sites More sharing options...
fenway Posted November 29, 2006 Share Posted November 29, 2006 In general, MySQL is not case-sensitive -- do you simply want to toss out the duplicates? Quote Link to comment Share on other sites More sharing options...
jaymc Posted November 29, 2006 Author Share Posted November 29, 2006 It is case sensitive because ive set the username field to BINARYI dont want to toss out the dupilicates, I basically want to turn the followingjamieJAMIEJamieinto thisjamieJAMIE01Jamie02 Quote Link to comment Share on other sites More sharing options...
fenway Posted December 3, 2006 Share Posted December 3, 2006 Interesting... I'm going to see what I can come up with. As a quick hack, just populate a temporary table with the lowercased usernames & counts, and then simply issue a multi-table update, and "skip" the first one of each username with an appropriate limit clause, and concatenate in the lpadded-number. Quote Link to comment 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.