using like and % in MySQLdb
gh at ghaering.de
Thu Aug 7 12:09:38 CEST 2003
Torsten Marek wrote:
> Dave Harrison schrieb:
>> Im sure this is a really obvious problem but :
>> """SELECT * FROM user WHERE login LIKE '%%s%'""", [login]
>> will not work ... gives me an "unsupported format character ''' (0x27)"
>> escaping the %'s with % as the doco recommends wont work either.
> Why don't you do
> """SELECT * FROM user WHERE login LIKE %s""", ("%"+login+"%", ))
You're right. Please ignore my previous post in this thread. It
correctly shows how to escape percent signs, but won't work in the SQL
More information about the Python-list