How can I retrieve issues in Jira that possess solely a certain label?

I am working with a label in Jira, for example, SampleLabel. My goal is to extract all issues that are associated only with that label and nothing else. What is the correct approach to achieve this?

I attempted the following:

labels = SampleLabel AND NOT(labels IN (Bar, Baz))

However, this returned issues that include both SampleLabel and AnotherLabel. My objective is to retrieve issues that exclusively have the label SampleLabel.

What is the right way to formulate a query in Jira to get issues with only a specific label?

you might try labels = SampleLabel AND labels not in (null), this will fetch items that only have SampleLabel and no other labels. sometimes, a label search using not in can be tricky in jira, so double-check what labels might be active outside ur search.

To retrieve issues in Jira with only a specific label, such as ‘SampleLabel’, you can use a JQL query that ensures the issue count matches your label count. A possible way is using labels in (SampleLabel) AND labels not in (all other potential labels). Alternatively, if your Jira instance supports the ScriptRunner add-on, you could achieve this through scripted fields, allowing for more precise control over the label filtering logic by using a script like issue.get('labels').size() == 1 AND 'SampleLabel' in issue.get('labels').

You can also use labels = SampleLabel AND labels not in (null, "other known labels"). sometimes by exclusion approach, you can miss some conditions, so make sure to list any other label explicitly to guarantee clarity. Hope this helps!