Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

This article explains how to use the CONCAT, JOIN, LEFT functions in MySQL using the app of MySQL in the SQL for Confluence (Pro Edition) app.

Instructions

Follow the steps:

  1. Log into the Confluence instance.

  2. Go to the required confluence page and edit the same.

  3. Add Insert a SQL macro and go to the the Edit option  option to open the settingsmacro editor.
    Image Modified
  4. Select the a Data source profile and write enter the required SQL statement as shown in the below imagequery in SQL statement. Follow this link to configure Data source profile.a.

    • CONCAT () - This function allows you to add two or more strings together.

      Code Block
      languagesql
      SELECT user_name, CONCAT (display_name,"  ", active,"  ",created_date) AS Userdetails
      FROM cwd_user;


      Image Modified

     Click on
    • Click Save settings

     and Update
    •  in the macro editor and Update to save the page edits.

    Image Removed
    • Image Added

    b.
    • JOIN A JOIN clause is used to combine rows from two or more tables, based on

    a related column between
    • column(s) common to both of them.

      In

    the below
    • this example,

    we have joined
    • a join is used on two tables cwd_user and cwd_group.

    Displayed the
    • The result is displayed based on the common columns in both the tables.

      Code Block
      languagesql
      SELECT user_name,last_name,group_name FROM cwd_user JOIN cwd_group on cwd_user.directory_id = cwd_group.directory_id;


      Image Modified

      Click on
    •   Click Save settings

     and Update
    •  in the macro editor and Update to save the page edits.
      Image Modified

    c.
    • LEFT () -

     This function
    •  This function is a string function that returns the left part of a string with a specified length. 

       
    • In

    the below
    • this example,

    the following
    • the statement uses the LEFT function to return the

    5
    • 10 leftmost characters of the string group_name. The long group_name can be displayed in a short form if required.

      Code Block
      languagesql
      SELECT 
          group_name, LEFT(group_name, 
    5
    • 10) summary
      FROM
          cwd_group;
    Image RemovedClick on
    • Image Added

     
    • Click Save settings
     and Update
    •  in the macro editor and Update to save the page edits.
    Image Removed
    • Image Added
Info