Jump to content

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


wright67uk

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?

 

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.