2

I am using SQL Developer. When I want to bind value. Normally I use following syntax:

    SELECT * FROM table WHERE column = :bindvalue

but, I don't know how to do that in string. The following query does not work.

    SELECT * FROM table WHERE column like '%:bindvalue%'

Why do I need it? Because my program runs a query in python and assigns something to bind variable:

    curr.execute('''SELECT * FROM table WHERE column''' = :bindvalue, bindvalue=somevalue)

1 Answer 1

6

Concatenate the prefix/suffix with the bind variable:

SELECT * FROM table WHERE column like '%' || :bindvalue || '%'
Sign up to request clarification or add additional context in comments.

2 Comments

In fact, it's so obvious that I'm ashamed. Thanks for the answer.
Thanks for this, helped me today. Note for MySQL, you would need to use CONCAT('%', :bindvalue, '%') OR have the PIPES_AS_CONCAT SQL mode enabled.

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.