From: Donal K. F. <don...@ma...> - 2013-01-02 14:48:30
|
On 02/01/2013 08:45, Anton wrote: > What is the right way to insert variable in " LIKE '%$var%' " style in tdbc::mysql prepare ? > Parameters only substitute for whole words (because they don't use string substitution under the covers, but rather injection as independent values into the *compiled* version of the query on the server side) so you need to use something like this: SELECT * FROM radcheck WHERE username LIKE '%' || :ffff || '%' (The “||” is the standard SQL string concatenation operator.) It's probably easier to just generate the whole search term with wildcards in Tcl first. Also, be aware that your query will necessarily do a linear table scan; you might wish to think whether you need such an approach... Donal. |