This article explains how to use the CONCAT, JOIN, LEFT functions in MySQL using the app SQL for Confluence (Pro Edition).
Instructions
Follow the steps:
Log into the Confluence instance.
Go to the required confluence page and edit the same.
- Add SQL macro and go to the Edit option to open the settings.
Select the Data source profile and write the SQL statement as shown in the below image. Follow this link to configure Data source profile.
a. CONCAT () - This function allows you to add two or more strings together.SELECT user_name, CONCAT (display_name," ", active," ",created_date) AS Userdetails FROM cwd_user;
Click on Save settings and Update the page.
b. JOIN - A JOIN clause is used to combine rows from two or more tables, based on a related column between them.
In the below example, we have joined two tables cwd_user and cwd_group. Displayed the result based on both the tables.SELECT user_name,last_name,group_name FROM cwd_user JOIN cwd_group on cwd_user.directory_id = cwd_group.directory_id;
Click on Save settings and Update the page.
c. LEFT () - This function is a string function that returns the left part of a string with a specified length.
In the below example, the following statement uses theLEFT
function to return the 10 leftmost characters of the stringgroup_name
. The long group_name can be displayed in a short form if required.SELECT group_name, LEFT(group_name, 10) summary FROM cwd_group;
Click on Save settings and Update the page.
- You can use any SQL functions and queries based on the requirement. It is not specific to the queries mentioned above.
- Refer the MySQL link https://dev.mysql.com/doc/refman/8.0/en/functions.html