0
input_uni = request.form.get("search")
uni = db.execute("SELECT * FROM unis WHERE name LIKE :name OR country LIKE :country", name=input_uni, country=input_uni)
2
  • Does name=f"%{inpunt_uni}%" do what you want? Commented Feb 9, 2021 at 16:47
  • Yes it did, Thank you so much jordamn Commented Feb 9, 2021 at 19:58

1 Answer 1

1

You clould use concat around you param name for build a proper like pattern without % issues

SELECT * FROM unis WHERE name LIKE concat('%', :name, '%')  
   OR country LIKE concat('%', :country, '%');
Sign up to request clarification or add additional context in comments.

2 Comments

Does using concat() have implications on index usage?
yes .. the use of function don't allow the use of index .. ....but also the use of wildchar in like produce bad performance .. so for like operator the use of caoncat is not so bad

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.