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

This widget could not be displayed.
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
This widget could not be displayed.

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'
This widget could not be displayed.

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 Tuesday in Jira

What modern development practices are at the heart of how your team delivers software?

Hey Community mates! Claire here from the Software Product Marketing team. We all know software development changes rapidly, and it's often tough to keep up. But from our research, we've found the h...

156 views 1 3
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