---
title: "How to use Confluence metadata in SQL queries"
canonical: "https://support.appfire.com/space/SUPPORT/89138517/How%20to%20use%20Confluence%20metadata%20in%20SQL%20queries"
format: markdown
---
## <span style="color: #000000">Description</span>

<span style="color: #000000">In many cases, you may want your query to know the current logged in user, what page the query is on, or other Confluence related metadata. This is easily done using the</span> [Run Self-Service Reports for Confluence](https://appfire.atlassian.net/wiki/spaces/RUN) <span style="color: #000000">and various</span> [pre-defined variables](https://appfire.atlassian.net/wiki/spaces/RUN/pages/73074529)<span style="color: #000000">. </span>

<span style="color: #000000">For </span>*<span style="color: #000000">SQL for Confluence</span>* [release 5.2](https://appfire.atlassian.net/wiki/spaces/SQL/pages/74319224) <span style="color: #000000">and later, a special substitution variable </span>**<span style="color: #000000">@user_id@</span>**<span style="color: #000000"> is available as well. The SQL macros replaces this text with the user ID of the currently logged in user or anonymous, if the user is not logged in.</span>