This article explains how we can change the case of values from any column from the MySQL table. To convert all the column values to uppercase the UCASE() function is used. Similarly to convert values to lowercase, the LCASE function is used.
The UCASE() function
The syntax of UCASE function is as follows:
SELECT UCASE(column) FROM table;
To convert all the values in a specific column of any table to uppercase using UCASE in MySQLi, pass the query for changing case to the query function of the mysqli object. The following example converts all values in patient_fname column to uppercase
Using UCASE Function in Mysqli connect_error) { die("Connection not established: " . $connection->connect_error); } $query = "Use Hospital;"; $connection->query($query); // Using UCASE Function $query = "SELECT UCASE(patient_fname) ". "FROM Patient "; $output = $connection->query($query); if ($output->num_rows > 0) { // output data of each row while($row = $output->fetch_assoc()) { echo "Patient Firstname " . $row["UCASE(patient_fname)"]."
"; } } else { echo "0 results"; } $connection->close(); ?>
The LCASE() function
The syntax of LCASE function is as follows:
SELECT LCASE(column) FROM table;
To convert all the values in a specific column of any table to lowercase using LCASE in MySQLi, pass the query for changing case to the query function of the mysqli object. The following example converts all values in patient_fname column to lowercase
Using LCASE Function in Mysqli connect_error) { die("Connection not established: " . $connection->connect_error); } $query = "Use Hospital;"; $connection->query($query); // Using LCASE Function $query = "SELECT LCASE(patient_fname) ". "FROM Patient "; $output = $connection->query($query); if ($output->num_rows > 0) { // output data of each row while($row = $output->fetch_assoc()) { echo "Patient Firstname " . $row["LCASE(patient_fname)"]."
"; } } else { echo "0 results"; } $connection->close(); ?>