Using of variables in SQL query
- Jan Vašátko
- Topic Author
- Offline
- New Member
-
- Posts: 3
- Thank you received: 0
Write Your SQL Query: If you want to write your custom MySQL queries to fetch data in order to generate charts, click on the “Write Your SQL Query” Button. A text area will be display with some notification saying that system will consider the first column for Horizontal value and except the first column, rest of the columns will be consider as series.
You can also include dynamic variables in your SQL query. You just need to enter variable name within curly braces. e.g. {catid}. {loggedinuserid} is reserved for Logged-in User
I don't understand the usage of the variables - what exactly are these variables? I would like to use SQL select like
select x, y
from #__table
where id = {articleid}
{articleid} should be the ID of the actual article. Can I use it this way? The purpose is to show different chart in every article.
Jan
Please Log in to join the conversation.
If Article ID is there in get / post data, then it can be used. And in frontend Article ID is available in "id" variable, that's why you should use {id} ( id get variable is available on Article detail layout if you are intending to display the module on Article detail layout )
Thanks
Daniel
Please Log in to join the conversation.
- Jan Vašátko
- Topic Author
- Offline
- New Member
-
- Posts: 3
- Thank you received: 0
select x, y
from #__table
where id = {id}
does not work (nothing shows). If I set
select x, y
from #__table
where id = 123
it is working. Are there some restrictions or should I use it spcial way-
Please Log in to join the conversation.
Thanks
Daniel
Please Log in to join the conversation.
- Jan Vašátko
- Topic Author
- Offline
- New Member
-
- Posts: 3
- Thank you received: 0
Please Log in to join the conversation.
SEF URL do not affect this functionality but as you said It's not working, It means the variable is not available in ID parameter. Please find it out which variable is being used and then update accordingly.
Thanks
Daniel
Please Log in to join the conversation.