Solved

MySQL

Posted on 2011-02-28
8
379 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
  • 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 40

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
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
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 40

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.

Join & Write a Comment

Loading csv or delimited data files to MySQL database is a very common task frequently questioned about and almost every time LOAD DATA INFILE comes to the rescue. Here we will try to understand some of the very common scenarios for loading data …
Creating and Managing Databases with phpMyAdmin in cPanel.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

743 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now