CASE Functions SQL

CASE functions are used to convert data into all upper case or all lower case. This may be desired to convert a name into a Url, create a title on a page or some other purpose.

To convert all of the characters in an expression into lower case the LCASE() function is used. Here is a simple example:

INSERT INTO fict_chars (name, book, author) VALUE (LCASE("Hermione Granger"), "Harry Potter", "J K Rowling")

This function can also be used to change values coming out of a table, for example:

SELECT name, LCASE(book) FROM fict_chars

This will change the names of the books containing our fictional character all to lower case, but only for our results. Unlike the INSERT INTO example above, it will not change the data within the table on the database.

UCASE works in much the same manner as LCASE, only with the opposite effect. All of the characters in the data are converted to upper case. Syntax in a SELECT statement might look like this:

SELECT UCASE(column) FROM table

< AVG Function SQL | COALESCE FUNCTION SQL >


Send notes in disappearing ink!

Interesting Pages