0

I am having two variables in grafana for data source MySql, one is Site where i have enabled multi value option and second is Topic. Now i want that if we select multiple values in Site variable, Topic variables should reflect those changes but that's not working.

Table i am using is this - enter image description here

Although normal query in mysql is working - sql query i wrote which is working fine -

select topic from problems_solved where Site in (select Site from problems_solved)

But in grafana its not working. I am trying this query - select topic from problems_solved where Site in(select ${Site} from problems_solved). I tried with other queries are well but its not working. Can somebody help me out here.

Thanks

3
  • Site = ${Site} expect only one value. What is the error in grafana for your working query ? Commented Oct 9, 2021 at 19:16
  • Yeah, that true. For grafana i am not getting any error only not seeing data. Can you wrote query for that. I am not able to figure out how to write query for this. Commented Oct 9, 2021 at 19:29
  • I am using only one table. Edited question as per as your comments. Commented Oct 9, 2021 at 19:45

1 Answer 1

8

Use variable fomating, which creates correct SQL syntax (and more effective approach + remove duplicates). You can use Grafana advanced variable format options. Example:

1.) Site variable:

SELECT DISTINCT Site 
FROM problems_solved

2.) Topic variable:

SELECT DISTINCT topic 
FROM problems_solved
WHERE Site IN (${Site:sqlstring})
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.