Binoy Babu
Binoy Babu

Reputation: 17139

SQLite querying for exact matches

SQLite statement 'abc' LIKE 'ABCd' will return true. So my question is how to make an SQLite query that will return only exact record matches for a particular query.

Upvotes: 1

Views: 3722

Answers (2)

Riddhish.Chaudhari
Riddhish.Chaudhari

Reputation: 853

The LIKE operator has two modes that can be set by a pragma. The default mode is for LIKE comparisons to be insensitive to differences of case for latin1 characters. Thus, by default, the following expression is true:

  'a' LIKE 'A'

But if the case_sensitive_like pragma is enabled as follows:

  PRAGMA case_sensitive_like=ON;

Then the LIKE operator pays attention to case and the example above would evaluate to false.

Upvotes: 2

Jwalin Shah
Jwalin Shah

Reputation: 2521

for exact record match you need to use = sign.

ex : abc = abc.

and if you want all records which contain abc words. You need to write

abc like '%abc%' in your sqllite query.

Upvotes: 1

Related Questions