SQL QUERY FOR LINKED TYPE for Project ABC

Can any one   help  me how to write SQL Query for Issue type Bug in Project . Feilds should be like below
Key
Summary
Component
Assignee
FixVersion
Cycle
Linked Issues with Link Type (This is the most important and I can’t get through the UI)
Test Status

3 answers

0 votes
Vasiliy Zverev Community Champion Dec 02, 2016

Here is SQL statement to get linked issues

select	*
from	jiraissue
join	issuelink	
	join	issuelinktype	
	on		issuelink.LINKTYPE = issuelinktype.ID
	and		issuelinktype.LINKNAME = 'Cloners' 
on	jiraissue.ID = issuelink.SOURCE

I don't know what is Cycle and Test Status... probably some of the custom addon fields...

But you may start with the MS SQL below

select 
	  CONCAT(P.pkey,'-',JI.issuenum) as 'Key'
	, JI.SUMMARY as 'Summary'
	,(SELECT Stuff(
		(SELECT ',' + C.cname FROM component C 
		 INNER JOIN nodeassociation NA ON JI.ID = na.SOURCE_NODE_ID AND NA.SINK_NODE_ID = C.ID 
		 FOR XML PATH('')
		), 1,1, '')) as Components
	, JI.ASSIGNEE as 'Assignee'
	,(SELECT Stuff(
		(SELECT ',' + PV.vname FROM  projectversion PV 
		 INNER JOIN nodeassociation NA ON JI.ID = na.SOURCE_NODE_ID AND NA.SINK_NODE_ID = PV.ID 
		 FOR XML PATH('')
		), 1,1, '')) as Components
	, IT.pname as 'IssueType'
	, ILT.LINKNAME as 'LinkName'	
FROM dbo.jiraissue JI
INNER JOIN dbo.project P on JI.PROJECT = P.ID
INNER JOIN dbo.issuetype IT ON IT.ID = JI.issuetype
INNER JOIN dbo.issuelink IL ON IL.SOURCE = JI.ID
INNER JOIN dbo.issuelinktype ILT ON ILT.ID = IL.LINKTYPE
WHERE IT.pname = 'Bug' AND ILT.LINKNAME = 'Duplicate'

I don't know what is Cycle and Test Status... probably some of the custom addon fields...

But you may start with the MS SQL below

select
      CONCAT(P.pkey,'-',JI.issuenum) as 'Key'
    , JI.SUMMARY as 'Summary'
    ,(SELECT Stuff(
        (SELECT ',' + C.cname FROM component C
         INNER JOIN nodeassociation NA ON JI.ID = na.SOURCE_NODE_ID AND NA.SINK_NODE_ID = C.ID
         FOR XML PATH('')
        ), 1,1, '')) as Components
    , JI.ASSIGNEE as 'Assignee'
    ,(SELECT Stuff(
        (SELECT ',' + PV.vname FROM  projectversion PV
         INNER JOIN nodeassociation NA ON JI.ID = na.SOURCE_NODE_ID AND NA.SINK_NODE_ID = PV.ID
         FOR XML PATH('')
        ), 1,1, '')) as Components
    , IT.pname as 'IssueType'
    , ILT.LINKNAME as 'LinkName'   
FROM dbo.jiraissue JI
INNER JOIN dbo.project P on JI.PROJECT = P.ID
INNER JOIN dbo.issuetype IT ON IT.ID = JI.issuetype
INNER JOIN dbo.issuelink IL ON IL.SOURCE = JI.ID
INNER JOIN dbo.issuelinktype ILT ON ILT.ID = IL.LINKTYPE
WHERE IT.pname = 'Bug' AND ILT.LINKNAME = 'Duplicate'

 

Also check: https://developer.atlassian.com/jiradev/jira-platform/jira-architecture/database-schema

to understand the JIRA scheme

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted 9 hours ago in Jira Service Desk

Looking for anyone who has switched from Zendesk to Jira Service Desk

Hi Community! The Jira Service Desk marketing team is looking for customers who have successfully switched from Zendesk to Jira Service Desk!   We’d love to hear your thoughts on the pros and ...

15 views 0 1
Join discussion

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you