0

python 2.4.1
mySQLdb 1.2.0
kernel 2.6.12

Hi,

How can I make the following statement so I can search for any string?

Right now I need to input at runtime %whatever I'm looking for% between % signs to get all records matching that query.

I want to have this statement set up so I do _not_ have to type the % at runtime.

This is what I have...

cursor.execute('select * from someTable where s_about like %s', (searchWhat))

any idea on how to achieve this?

el chupacabra

3
Contributors
2
Replies
4
Views
12 Years
Discussion Span
Last Post by locosway
0

The problem is in your syntax. You need to join the strings together, an easy way to do this is:

cursor.execute('select * from someTable where s_about like ' + variable + ';')
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.