Then again, MySQL does provide exactly what you need -- the "LOWER" function -- so you can skip the initial query and just do the update:"SELECT rec,id from memrecs where rec collate latin1_bin rlike '[A-Z]' +" );
Or, you could just apply the LOWER() function whenever you query the table to get "rec" values (SELECT LOWER(rec) ...) and not worry about whether or not there are capital letters in that column of the database.$dbh->do( "UPDATE memrec set rec=LOWER(rec)" );
A few other points you should know:
That's the wrong way to check for upper case letters -- you would want $_rec =~ /[A-Z]/ instead. Also, the "g" modifier does not apply to the tr/// operator (study the section about tr/// in perlop for details on its modifiers).if ( $_rec =~ /A .. Z/) { $_rec =~ tr/A-Z/a-z/g; ... }
But the regex match is unnecessary anyway. The two steps can be simplified to just this:
if ( $_rec =~ tr/A-Z/a-z/ ) { # tr/// returns the number of characters converted # so we get here only if there had been at least one A-Z }
In reply to Re: Checking MySql for capital letters
by graff
in thread Checking MySql for capital letters
by ukndoit
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |