mycursor.execute("SELECT PK FROM customers WHERE name = %s" % customer)
Customer is a string.
I am new at MySQL and i'm doing an app in python and i have a problem with WHERE clause. This code generates this error:
Unknown column 'Tomas' in 'where clause'.
Tomas is the name i want to find in my database.
My database looks has atributes: PK, name, surname, age, contact and 3 instances which one of them is Tomas. What am i doing wrong ?
You might want to have the name compared as a string instead of another column which is what i think mysql is doing. Try this
mycursor.execute("SELECT PK FROM customers WHERE name = `%s`" % customer)
NOTE: The string formatter is enclosed in backticks.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With