0

In SQL, does 'A' = 'a'?

I took results that I downloaded using sql, the values in two columns matched but they were not supposed to. When I tried to look for a difference, the only difference were capitalized letters in the middle of the word.

Is there a way to make SQL case insensitive? For example THERE is equal to There which is also equal to there or thERE?

Bohemian
  • 412,405
  • 93
  • 575
  • 722

2 Answers2

1

Use LOWER function to convert the strings to lower case before comparing.

like this :

SELECT *
  FROM tableName
 WHERE LOWER(columnName)='a'

using ILIKE instead of LIKE

SELECT * FROM tablename WHERE columnName ILIKE 'a'
Mukesh Kalgude
  • 4,814
  • 2
  • 17
  • 32
  • FWIW, the linked answer for this suggests NOT using ilike, as it is not a sequential read/not using any indexing when searching. – RonManning Apr 27 '23 at 11:48
-1
SELECT * from table_name where col ilike 'a'

using ilike or lower() or upper()

SIDU
  • 2,258
  • 1
  • 12
  • 23