?
Solved

MySQL

Posted on 2011-02-28
8
Medium Priority
?
385 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:
Cornelia Yoder earned 1000 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 1000 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
Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

 
LVL 27

Expert Comment

by:Cornelia Yoder
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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
In this article, we’ll look at how to deploy ProxySQL.
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

800 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