Can certain DB Fields be set to UPPERCASE?

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Can certain DB Fields be set to UPPERCASE?

Post by simonmlewis »

We need to set ALL entries in three MySQL Database fields to be in all UPPERCASE.
Is there a script that can be run to do this?

These are used dynamically for META TAGS, so it's not about how to render it on screen.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Can certain DB Fields be set to UPPERCASE?

Post by requinix »

simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: Can certain DB Fields be set to UPPERCASE?

Post by simonmlewis »

Sorry? Where in there does it say how to convert a field to UPPERCASE within the database itself?
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Can certain DB Fields be set to UPPERCASE?

Post by requinix »

I linked a MySQL function. You're supposed to use that in an UPDATE query.
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: Can certain DB Fields be set to UPPERCASE?

Post by simonmlewis »

Sorry didn't see a function that explained it would do that.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Can certain DB Fields be set to UPPERCASE?

Post by Christopher »

As in: UPDATE foobar SET foo=UPPER('bar') WHERE id='foo'

You can also use the PHP strtoupper() function.
(#10850)
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: Can certain DB Fields be set to UPPERCASE?

Post by simonmlewis »

But you cannot run a script within phpmyadmin (directly on the server) to set those fields to be UPPERCASE ?

Code: Select all

UPDATE products SET metadescription=UPPER('bar')
What is "bar" ??
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Can certain DB Fields be set to UPPERCASE?

Post by requinix »

The field.

Code: Select all

UPDATE products SET metadescription = UPPER(metadescription)
You need to take a day out of your busy schedule to learn SQL. Not just the syntax but how it works and what it is capable of. Because there is much more to it than simple INSERT and SELECT statements.
Post Reply