Resolving local HTML storage replacement

I am experimenting with a simple HTML5-based repository, and I am having problems replacing the parameters (possibly) in my code.

The SQL string I want to execute is:

SELECT name, title FROM testTable WHERE name LIKE '%test%';

so my javascript line looks something like this:

tx.executeSql( "SELECT name, title FROM testTable WHERE name LIKE '%?%'", [ search_string ],

This fails (I think) because it is ?considered as a literal, and therefore the parser complains about too many parameters ( search_string).

I optimistically tried to use ???and ["'%", search_string, "%'"], but the same result.

Any suggestions - I imagine something really obvious, so please be careful.

+3
source share
1 answer

What about:

tx.executeSql( 
    "SELECT name, title FROM testTable WHERE name LIKE ?", 
    [ '%'+search_string+'%' ]
    );
+3
source

Source: https://habr.com/ru/post/1790828/


All Articles