Solved

MySQL

Posted on 2011-02-28
8
383 Views
Last Modified: 2012-05-11
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
0
Comment
Question by:Richard Korts
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
8 Comments
 
LVL 27

Accepted Solution

by:
yodercm earned 250 total points
ID: 35003302
.... SET Field = CONCAT(UCASE(SUBSTRING($input,1,1), SUBSTRING($input,2)))
0
 

Author Comment

by:Richard Korts
ID: 35013184
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
 
LVL 41

Assisted Solution

by:Sharath
Sharath earned 250 total points
ID: 35013542
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
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
LVL 27

Expert Comment

by:yodercm
ID: 35014162
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
 
LVL 41

Expert Comment

by:Sharath
ID: 35014743
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
 

Author Comment

by:Richard Korts
ID: 35062791
OK, I'm fine with that. How do I "request moderator for split of points"?
0
 

Author Comment

by:Richard Korts
ID: 35071985
To yodercm & Sharath_123:

I requested a moderator to split the points.

rkorts
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In this installment of my SQL tidbits, I will be looking at parsing Extensible Markup Language (XML) directly passed as string parameters to MySQL 5.1.5 or higher. These would be instances where LOAD_FILE (http://dev.mysql.com/doc/refm…
Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question