Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Database SELECT to get all label from a specific space

Hello together, 

I search a SELECT to get a list of all labels in a specific space (by SPACE-ID) on the database.

I have already tried a few things here, but nothing gave the right result. 

Yes I know, it gives a macro with options, that I got all labels from a specific space. But I think the macro gives to much results.

Can anyone help me?


1 answer

1 accepted

1 vote
Answer accepted
Dominic Lagger Community Leader Oct 14, 2020

Hi @Henning Karl 

I tried a bit and think got a good statement:

Select cl.labelid, l.name, s.spacekey, count(l.name) as count from content_label cl
join label l on l.labelid = cl.labelid
join content c on c.contentid = cl.contentid
join spaces s on s.spaceid = c.spaceid
where c.CONTENT_STATUS != 'deleted' and c.contenttype != 'SPACEDESCRIPTION' and s.spacekey = 'SPACEKEY' group by cl.labelid, s.spacekey, l.name
order by count desc;

This makes a list of all labels of a space. But not "Spacedescriptions" and not deleted pages.

Hope this is a good hint for you.

Regards, Dominic

Hi @Dominic Lagger 

I tried your SQL and it's almost perfect.

I added the following phrase on the where clause, because the SQL returned additional all favourites from each users from the pages in the space.  

and l.name != 'favourite

So the SQL is now this one:


Select cl.labelid, l.name, s.spacekey, count(l.name) as count from content_label cl
join label l on l.labelid = cl.labelid
join content c on c.contentid = cl.contentid
join spaces s on s.spaceid = c.spaceid
where c.CONTENT_STATUS != 'deleted' and c.contenttype != 'SPACEDESCRIPTION' and s.spacekey = 'SPACEKEY' and l.name != 'favourite' group by cl.labelid, s.spacekey, l.name
order by count desc;

Thanks a lot of your help.

Kind regards, 
Henning

Like Dominic Lagger likes this

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
VERSION
8.5.1
TAGS
Community showcase
Published in Confluence

Announcing Team Calendars in Confluence Data Center

Hi Community! We're thrilled to share that Team Calendars for Confluence is now a built-in feature for Confluence Data Center releases 7.11 and beyond.  A long time favorite,  Team Cale...

177 views 0 6
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you