A database table may contain any data according to the data types specified for the columns. The same can be retrieved through SQL statements and can be used in Confluence pages by using the SQL for Confluence app. When the table data is having link(s), the query results display the data as a plain text but not as clickable links. This article explains how to make the links in a database table clickable to be able to navigate to the respective address upon clicking on it them using SQL for Confluence app.
Instructions
- Add a SQL query macro on a in the intended Confluence page.
Add SELECT statement as given below in the macro:
Code Block theme Midnight select ID, CONCAT('[',Link,']') as url from pagelinks;
In the above this sample query, pagelinks is the table name, Link is the column that has links to other confluence pages on our in the instance.
- Set the output format of the SQL macro to Wiki as shown in the below screenshot below:
- The output is shown as mentioned in the below screenshot:
If a table has empty or blank strings,
...
the cell
...
has the text
...
"[ ]".
...
To display
...
null value when the column is empty, modify the SQL query as given below
Code Block | ||
---|---|---|
| ||
select CASE WHEN "url" = '' THEN NULL ELSE CONCAT ('[',url,']') END as Link, id from pagelinks; |
Note |
---|
The above mentioned SQL query is tested successfully on Mysql and Postgres databases. |
...