sqlpostgresqlvariablesgrafana

Use variable grafana in query with LIKE


I'm trying to create a query in GRAFANA with LIKE using the internal variables of the tool, but it informs the value of the variable with '' and this is generating an error in the query within postgres, any suggetions?

QUERY:

select count(*) from table_name where column_name like ('%'$VARIABLE'%') LIMIT 1

OUTPUT:

pq: syntax error at or near "'VALUE_VARIABLE'"

Solution

  • How about this:

    select count(*) from table_name where column_name like concat ('%', $VARIABLE, '%') LIMIT 1