Jump to content

Is there a way to change all of my values within a mysql table to proper case?


Recommended Posts

Is there a way to change all of my values within a mysql table to proper case?

 

At the moment I have some values as upper and others as lower.

I have mysql admin.

 

Is this possible, or would it be easier to transfer my data into excel for processing?

 

You can simply extract the values from your database and use strtoupper() to convert the data to uppercase. If you want to store the values into your db as uc words. You can use the mysql string function upper()

It can all be done with one simple query using UCASE() or LCASE(). If you want first letters upper or some other combination that will take a bit of extra work.

 

UPDATE table SET field = LCASE(field)

Thankyou, that is great to know.  I do need to change the values to First Letter Capitals but I wasn't too sure if it was possible within mysql.

 

<?php
$subtype = $_GET['subtype'];

echo "<h1>$subtype</h1>";
$query = "SELECT name, phone, email, WebAddress, postcode FROM business WHERE subtype ='$subtype' AND confirmed ='Yes' ORDER BY name";
if( $result = mysql_query($query) ) {
echo mysql_error();
while($row = mysql_fetch_assoc($result) ) {
	foreach( $row as $k => $v ) {
		if( empty($v) ) {
			unset($row[$k]);
		}
	}
	if( !empty($row['postcode']) ) {
		$row['postcode_link'] = "<p class=link><a href='/gmap.php?postcode=" . urlencode($row['postcode']) . "'>Map</a></p><br>";
	}
	echo implode( '<br>', $row);
}
}
?>

 

The results in the query above would be using the first letter capitals. 

Im not bothered if this is stored in mysql or wether it is just formartted in php, just a bit gazumped when it comes to doing it.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.