Reputation: 771
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'"
Upvotes: 0
Views: 10482
Reputation: 41
You can use regex for LIKE =~
or NOT LIKE !~
AND field =~ /*strew*/
Upvotes: 0
Reputation: 26
How about this:
select count(*) from table_name where column_name like concat ('%', $VARIABLE, '%') LIMIT 1
Upvotes: 1