Reputation: 53
I am trying to create a formatted string for a WHERE
clause.
I need to insert LIKE
syntax inside the FORMAT()
function.
Here is my SQL code snippet:
FORMAT(' AND student_name LIKE %%L% ', CAST(jsnData->>'term' AS VARCHAR) );
Upvotes: 0
Views: 1421
Reputation: 247790
As the documentation says,
In addition to the format specifiers described above, the special sequence
%%
may be used to output a literal%
character.
So your expression should be
format($$ AND student_name LIKE '%%' || %L || '%%' $$, jsnData->>'term')
(The cast is unnecessary.)
Upvotes: 2