sql 在 where in 子句中使用不区分大小写的匹配
sql use case insensitive match in where in clause
挑战:
Display the title of all the books and the isbn from Books database where the CATEGORY is in BUSINESS. The solution shouldn't be dependent on a specific case for the CATEGORY.
我通常会这样解决,但是最后一部分让我感到困惑。
SELECT title, isbn
FROM books
WHERE category in ('BUSINESS');
有人有什么建议吗?
使用 LOWER
函数,以便始终以小写字母进行比较:
SELECT title, isbn
FROM books
WHERE LOWER(category) in ('business');
挑战:
Display the title of all the books and the isbn from Books database where the CATEGORY is in BUSINESS. The solution shouldn't be dependent on a specific case for the CATEGORY.
我通常会这样解决,但是最后一部分让我感到困惑。
SELECT title, isbn
FROM books
WHERE category in ('BUSINESS');
有人有什么建议吗?
使用 LOWER
函数,以便始终以小写字母进行比较:
SELECT title, isbn
FROM books
WHERE LOWER(category) in ('business');