i have a table with some email fields. Some email records are in capital letters and some in camel case . Now i have to convert all the emails with capital letters to small letters. I can do that with a PHP script by fetching every record then checking it for any capital letters and then converting it to lowercase if any capital letter is found.
Is there any way in Mysql with which we can get only those records that contains capital letters in them and not all?? This way i will be spared by executing each and every record. Iam looking for a way in Mysql with which we can check for capital letters in a record in query itself . Any suggestions??
Change the collation to a case-sensitive collation.
But really, how long will this query take?
update `table` set email = lower(email)
Edit: update only records containing not only lower case emails:
update
`table`
set
email = lower(email)
where
email <> lower(email)
collate
latin1_general_cs
You can test this by selecting them first:
select
*
from
`table`
where
email <> lower(email)
collate
latin1_general_cs
limit
10