|
Graham Dumpleton
grahamd at dscpl.com.au
Thu Jan 26 18:46:05 EST 2006
Luis M. Gonzalez wrote ..
> I tried this:
> ("select * from customers where company like %s%" %company ) # doesn't
> work
> ("select * from customers where company like '%(%s)%" %company # doesn't
> work either
>
> The question is:
> How should a include the parameter into de LIKE clause in order to accept
> only a part of the full company name and return the matching results?
Double up the"%" to get an actual percentage passed through.
("select * from customers where company like %s%%" %company )
At least that would be the problem if it is simply using "%" operator on
string:
>>> "select * from customers where company like %s%" % "ME"
Traceback (most recent call last):
File "<stdin>", line 1, in ?
ValueError: incomplete format
>>> "select * from customers where company like %s%%" % "ME"
'select * from customers where company like ME%'
Graham
|