Can't remember how to use LIKE in SQL statement and use of ' in string

This is where I get a Nil exception:

rs = db.SQLSelect("SELECT type, body FROM testdata WHERE (type = 5 OR type = 6) AND body LIKE '%0193039239%' ORDER BY dateandtime ASC")

It runs fine when I execute it directly in Postgres Database so it must have something to do with the use of ’ inside a string. When I took the LIKE part out, it executed fine.

I vaguely remember that I have to use the \ character somehow but I couldn’t find it in the documentation nor through Google.

Thanks in advance,


That SQL statement is fine. Instead, check to make sure that db is not nil, and that you’ve actually connected the database. Always check db.Error after executing any command to see if there was any problem with it. The error message will tell you what when wrong.

Shame on me, I did indeed forget to connect to the Db first. I need to make sure this action event is only execute when I’m connected. Thanks for the quick help, @Kem Tekinay

Case closed


there is a button that adds a check to flag you get the searched answer.

FWIW: SQLite home web location is