Reputation: 2686
I am looking to update the field 'prefix' in my course table to just have the FIRST letter capitalized and not the whole prefix.
Is there any easy way to do this is SQL?? Sample Output could look like 'Aadm' in the database for 'prefix'.
My table looks like:
Sample rows look like:
I have SQL that looks like:
WHERE CONCAT(prefix,code) LIKE '%". $keywords . "%'");
Is it possible to user LOWER on prefix here?
Upvotes: 0
Views: 237
Reputation: 56357
select prefix,
concat(upper(substring(prefix,1,1)),substring(lower(prefix) from 2)) as initcap
from course
try it in select form before update your field
if you're looking for prefixes where all chars are upper case use a regexp
where binary(prefix) regexp '^[A-Z]+$'
EDIT. Update query
update course
set prefix =
concat(upper(substring(prefix,1,1)),substring(lower(prefix) from 2))
Upvotes: 1