首页 > 解决方案 > 使用 LIKE 在查询中使用变量 grafana

问题描述

我正在尝试使用工具的内部变量在GRAFANA中使用 LIKE 创建一个查询,但它会通知变量的值,''这会在 postgres 中的查询中产生错误,有什么建议吗?

询问:

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

输出:

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

标签: sqlpostgresqlvariablesgrafana

解决方案


这个怎么样:

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

推荐阅读