Proper way to make a case-insensitive query on a string column?
See original GitHub issueI have an entity with a string
column, and I’m importing external data into the table. I want to be able to do a case-insensitive query against the column, because it’s based on user input.
I’d like to know if there’s a way other than normalizing my data in the db to lowercase (which would be inconvenient because I need to display this string back to the user in its original case) and user query.
I’m using a Repository.find({stringColumn: userInput})
to fetch my data.
Issue Analytics
- State:
- Created 6 years ago
- Comments:15 (1 by maintainers)
Top Results From Across the Web
Case insensitive SQL SELECT query examples
The SQL standard way to perform case insensitive queries is to use the SQL upper or lower functions, like this: select * from...
Read more >How to make "case-insensitive" query in Postgresql?
Use LOWER function to convert the strings to lower case before comparing. Try this: SELECT id FROM groups WHERE LOWER(name)=LOWER('Administrator').
Read more >Case-Insensitive Search in SQL - Use The Index, Luke
Ignoring the case in a where clause is very simple. You can, for example, convert both sides of the comparison to all caps...
Read more >How to do case-insensitive and accent-insensitive search in ...
To find all the people who have Barry for any of their names, you can (upper- or) lowercase the column and search string:...
Read more >Controlling Case Sensitivity in String Comparisons - O'Reilly
In summary, comparisons are case sensitive if they involve a binary literal string or string expression, or a CHAR BINARY , VARCHAR BINARY...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
For those using postgres, the
ILIKE
operator perform case insensitive queries:* Notice I’m using
" "
to specify the column and' '
to specify the searched keyword. Double quotes are used for quoted identifiers and single quotes for string literalsThis open issue is about including the
ILIKE
operator as a typeorm advanced option, which would be the ideal solution for postgres users.I guess you need something like this:
Can you try to do it following way: