How SQLite Quote() Works

The SQLite quote() function allows you to escape a string so that it’s suitable for inclusion in an SQL statement.

Strings are surrounded by single-quotes with escapes on interior quotes.

BLOBs are encoded as hexadecimal literals.

Note that strings with embedded NUL characters cannot be represented as string literals in SQL. If you include strings with embedded NUL characters, the returned string literal is truncated prior to the first NUL.

Continue reading

Difference Between NullIf() and IfNull() in SQLite

SQLite has a function called nullif() and another function called ifnull(), each of which serve a different purpose.

  • nullif() allows you to treat certain values as NULL. You can think of it as “return NULL if …”.
  • ifnull() allows you to replace NULL values with another value. You can think of it as “if NULL, then …”.

So they basically do the opposite of each other. One replaces NULL values with another value, and the other replaces another value with NULL.

Continue reading