2

This is a follow-up from this question. Although I can write a non-binary LIKE query such as - SELECT COUNT(*) FROM TABLE WHERE MID LIKE 'TEXT%' in raw SQL, I would like to know if it's possible through the Django ORM.

Both startswith and contains seem to be using a binary pattern search.

1 Answer 1

8

Try istartswith and icontains, which in MySQL resolve to LIKE rather than LIKE BINARY.

Note that with MySQL, the case-sensitivity of the comparison depends on the collation set in the database (meaning that i lookups may still be case-sensitive!).

Sign up to request clarification or add additional context in comments.

1 Comment

You're right. How could I have forgotten about that?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.