Search code examples
csqlitesql-like

How do I embed the sqlite LIKE command in C?


I have the following query:

SELECT * FROM versions WHERE path LIKE '%/dir1%'

that works perfectly fine when executing from sqlite command prompt.

However, I am having trouble running this command from a C program.

It is a little bit tricky because in sqlite the %Q is used to pass in strings but LIKE also uses % to perform regular expression behavior.

Which sqlite function should I use from the API?


Solution

  • %% is converted to %.

    Making an answer to get accepted :)