Hi,
Is there a good way to build queries with LIKE and %?
I would like to do something like this:
db.Select(&pp, "SELECT * FROM places WHERE LOWER(country) LIKE %?%", search)
I know I can concatenate % with search outside of the query, but I just ask if there is something better.
Hello,
You can embed the % in your query param, eg:
db.Select(&pp, "SELECT * FROM places WHERE lower(country) LIKE ?", "%"+search+"%"))
This should still be safe from injection attacks.
Most helpful comment
Hello,
You can embed the
%in your query param, eg:This should still be safe from injection attacks.