MySQL

Is there a way to force the first letter of a field in a MySQL table to be upper case?

So when the INSERT (or UPDATE) is done, if the first letter is lower case, it makes it upper case?

Thanks
Richard KortsAsked:
Who is Participating?
 
Cornelia YoderConnect With a Mentor ArtistCommented:
.... SET Field = CONCAT(UCASE(SUBSTRING($input,1,1), SUBSTRING($input,2)))
0
 
Richard KortsAuthor Commented:
yodercm:

I am using php strings on a web server to update & insert data.

I'm not clear on where I put this.

In the table definition?

Thanks
0
 
SharathConnect With a Mentor Data EngineerCommented:
Create an AFTER INSERT trigger on your table. That will take care of updating the first letter of the field to upper case every time.
Replace the table and column names with your actual table and column names.
CREATE TRIGGER FirstLetter AFTER INSERT ON your_table
  FOR EACH ROW BEGIN
    UPDATE your_table SET Field = CONCAT(UCASE(SUBSTRING($input,1,1), SUBSTRING($input,2)))
  END;

Open in new window

0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
Cornelia YoderArtistCommented:
Thanks a lot for the points (NOT) for giving you the MySQL structure you asked for.  I'm sure Sharath appreciates getting all the points for incorporating my answer.
0
 
SharathData EngineerCommented:
I expect a split of points here as yodercm has provided you the actual logic and I just gave you a suggestion on how to implement that logic.
yodercm -  you can request moderator for split of points. I am happy for that.
0
 
Richard KortsAuthor Commented:
OK, I'm fine with that. How do I "request moderator for split of points"?
0
 
Richard KortsAuthor Commented:
To yodercm & Sharath_123:

I requested a moderator to split the points.

rkorts
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.