SQLite - how to query a field with partial data?

Hello all.

I need to query a table’s field for the letters NRC (as upper case). The field may have other characters in it but I am looking specifically for these 3 characters in Upper Case and together - not separated.

Using SQLite and Postgre, but SQLite to start.

Thank you!

select * from mytable where myfield like '%NRC%'

Select * from table where field like ‘%NRC%’;

…by a nose… :slight_smile:

at least we answered the same result !

In PostgreSQL, LIKE is case sensitive, but in SQLite, “field LIKE ‘pattern’” is not case sensitive by default.

SQLite will normally match any case of NRC: nrc, Nrc, nRc, nRC, and so on.
If you need SQLite to be case sensitive, issue a pragma statement before your query:

mydb.SQLExecute("PRAGMA case_sensitive_like = true;")