开发者

Easy way to update certain field in database that is upper case?

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:

Easy way to update certain field in database that is upper case?

Sample rows look like:

Easy way to update certain field in database that is upper case?

开发者_StackOverflow中文版

I have SQL that looks like:

WHERE CONCAT(prefix,code) LIKE '%".  $keywords . "%'");

Is it possible to user LOWER on prefix here?


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)) 
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜