Using SQL like '%%' in my query (filter)

I am trying to use SQL like ‘%{{my_text_var}}%’ in my query where clause.
Is this possible? If not, any suggestions on how to use a “contains” type of query?

Hi,
if you want to use the metabase filters I find it very helpful to use the suggestions they give how to build the variable syntax, click on “variables” on the right site above the SQL editor (next to the save button). There are the types of variables explained.

For a “contains” type I use [[LIKE CONCAT (’%’,{{var}},’%’)]] - you need CONCAT to combine the “%” with the variable. Hope it works for you :slightly_smiling_face:
Eva

3 Likes

Thank you, that worked!

1 Like

its dont work for me Error is =An expression of non-boolean type specified in a context where a condition is expected, near ‘GROUP’.

Hi, can you share your SQL syntax?

İm fixed Thank you ‘%’+{{Abay}}+’%’ is now work

1 Like

Thank you, it works, but how to deal with multiple fuzzy query conditions for a field?
such as,
select nick,title from demo where title like '%A%' or title like "%B%"

thank,you.I have found a solution.
`select nick,title from demo where title regexp {{title}}
title=A|B

This is no longer needed - you can now do:

[[name LIKE "%"{{name}}"%"]]

Note: Make sure you have double quotes and not smart-quotes. For me, the parent answer didn’t work because when I copy and pasted it ended up with smart-quotes.