0

I'm using MySQL with Python Flask and trying to do a search query with LIKE concat however I am getting a Syntax error with it or a Type Error if I use different marks around my symbols.

name_search = form.name.data
cursor.execute('SELECT id, name, surname FROM users WHERE surname LIKE CONCAT ('%', '%s', '%')', [name_search])

1 Answer 1

1

You could add the percentage signs within the variable

cursor.execute("SELECT id, name, surname FROM users 
    WHERE surname LIKE '{}'".format("%" + name_search + "%"))
Sign up to request clarification or add additional context in comments.

1 Comment

Was able to use this to get to where I needed thank you!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.