MYSql, CGI web page search code not working
Kirk McDonald
mooquack at suad.org
Sat Jan 28 13:35:13 EST 2006
Fred wrote:
> OK one more... how would I do a "LIKE" instead of a = in this code?
>
> cursor.execute("Select * from phone where name=%s order by name",
> (form['name'].value,))
>
> Right off I think:
>
> cursor.execute("Select * from phone where name like %%s% order by
> name",
> (form['name'].value,))
>
> But it blows up...
>
This should work:
cursor.execute("Select * from phone where name like %s order by name",
('%'+form['name'].value+'%',))
-Kirk McDonald
More information about the Python-list
mailing list