+ 2
SQL - diference about when to use UPPER and LOWER
what is the difference between lower and upper if this pattern is case insensitive
7 Réponses
+ 2
There is no difference for insensitive pattern. You can convert text to lower or to upper.
+ 2
, SQL is not a case-sensitive language, so it doesn't matter if you use upper case or lower case for SQL commands. However, it's recommended to use a consistent capitalization style for better code readability and maintainability
+ 2
SELECT UPPER(column_name) FROM table_name; SQL.
SELECT UPPER(Name) AS UpperCaseName FROM Employees; SQL.
SELECT LOWER(column_name) FROM table_name; SQL.
SELECT LOWER(Name) AS LowerCaseName FROM Employees; SQL.
+ 1
That's what I thought, but when I was doing this part of the course it seemed like there was a logic in when to use UPPER or LOWER, so much so that it marked it wrong twice, but if it was insensitive, couldn't I use any of the commands?
+ 1
There is no difference between lower and upper it is an insensitive pattern to convert text.
+ 1
Let's consider this scenario.
Suppose you are searching a book from a library, and you already know the book name, such as "The Hunt for Red October", and the library does have this book.
How would you make a search?
1. the hunt for red october
2. The Hunt for Red October
3. THE HUNT FOR RED OCTOBER
4. The Hunt For Red October
I think most of the people will type 1 because we are lazy to type the entire name with the "correct capitalization."
Because the library record the book name in the correct capitalization, if you type in option 1, there will be no result return to you and telling you the book does not exist, which is incorrect.
By turning both the recorded book name in the system and your search text into the same capitalization, it will find a match, no matter how you search in the above 4 options.
+ 1
I think you need to convert both sides which will be compared with each other. So you make it case insensitive.
Which course or task you mean, from where?