using like and % in MySQLdb
gh at ghaering.de
Thu Aug 7 11:21:01 CEST 2003
Dave Harrison wrote:
> 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. [...]
It _will_ work. You'll have to escape the first and the last percent
sign with another percent sign and leave the %s in the middle untouched.
"SELECT * FROM user WHERE login LIKE '%%%s%%'"
More information about the Python-list