MySQL UPPER and LOWER
The UPPER function converts a string to uppercase, and the LOWER function converts a string to lowercase. These functions are useful for case-insensitive comparisons and formatting.
Examples with Tamil Kings
1. Converting King’s Name to Uppercase
SELECT king_name, UPPER(king_name) AS uppercase_name FROM tamil_kings_auto_increment;
Code Explanation: This query converts king_name to uppercase and renames the result as 'uppercase_name'.
2. Converting King’s Name to Lowercase
SELECT king_name, LOWER(king_name) AS lowercase_name FROM tamil_kings_auto_increment;
Code Explanation: This query converts king_name to lowercase and renames the result as 'lowercase_name'.
Best Practices
- Use
UPPERandLOWERfor case-insensitive text comparisons. - Be mindful of the impact on performance when using these functions in WHERE clauses.
Key Takeaways
UPPERconverts text to uppercase, andLOWERconverts text to lowercase.- These functions are useful for formatting and case-insensitive operations.