'How to use like in MySQL query in Grafana?

I am working in grafana with MySQL. I have a template variable and it has multiple values and I want to use that template variable with MySQL query using 'like' keyword.

For Example:

select column_name from table_name where column_name like ('%'$Variable'%');

Here I ended up with Mysql syntax error or query failed in grafana.

I am looking the same as this stackoverflow question

How can I achieve this ?



Solution 1:[1]

You can concatenate $Variable with the wildcards:

select column_name 
from table_name 
where column_name like concat('%', $Variable, '%');

Solution 2:[2]

.... where column_name in ($Variable) ;

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 forpas
Solution 2 SimonaR