python 2.4.1
mySQLdb 1.2.0
kernel 2.6.12


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

Recommended Answers

All 2 Replies

Not all of us are familiar with the mySQLdb module. Can you give us a little more info?

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 + ';')
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.