Not able to bind a variable to a "LIKE" statement in sqlite

Discuss any general programming issues here
Post Reply
zenzizenzizenzic
Posts: 28
Joined: Fri Mar 15, 2019 2:35 pm

Not able to bind a variable to a "LIKE" statement in sqlite

Post by zenzizenzizenzic »

Using the following code

Code: Select all

  local statement=db:prepare([[SELECT sort_name, Name from Author where Name LIKE :za ]])
  statement:bind_names({za=filter})
I keep getting no results.
I get full results when I remove the "where Name LIKE :za".
Also, I get results when I run the SQL in the SQLMan with the like included.

The value of filter I pass in for testing is

Code: Select all

'%a%'
Any help would be appreciated!

zenzizenzizenzic
Posts: 28
Joined: Fri Mar 15, 2019 2:35 pm

Re: Not able to bind a variable to a "LIKE" statement in sqlite

Post by zenzizenzizenzic »

Apparently you can't have the ' around the bind value.

Post Reply