SQL upper

Created By: chatGPT

In SQL, the UPPER function is used to convert a string to uppercase. This can be particularly useful when comparing strings in a case-insensitive manner or when you want to ensure that all data is uniformly displayed. The syntax for the UPPER function is quite simple.
UPPER(string_expression)
Here’s an example of how to use the UPPER function within a SQL query. Suppose you have a table named employees and you want to select all employees whose first names start with 'j' regardless of the case used in the database.
SELECT * FROM employees WHERE UPPER(first_name) LIKE 'J%';
In this query, the UPPER function ensures that any variation of 'J' (like 'j', 'J') is considered. This results in returning all relevant records without missing any due to case differences.
You can also use UPPER in an UPDATE statement. For instance, if you want to standardize the first names of employees to be in uppercase, you could do the following:
UPDATE employees SET first_name = UPPER(first_name);
It’s important to note that the UPPER function does not alter the original data in the table until an UPDATE statement is executed. However, when used in a SELECT query, it will only affect the output of that specific query.
Introduction And SetupSelectFromWhereJoinInner JoinLeft JoinRight JoinFull JoinOnGroup ByHavingOrder ByLimitInsert IntoValuesUpdateSetDeleteCreate TableAlter TableDrop TableCreate IndexDrop IndexUnionUnion AllIntersectExceptCaseWhenThenElseEndInBetweenLikeIs NullIs Not NullExistsNot ExistsAndOrNotAsWithDistinctCountSumAvgMinMaxCastCoalesceNullifSubstringConcatLowerUpperTrimReplaceRoundFloorCeilAbsModCurrent_dateCurrent_timeCurrent_timestamp