简体   繁体   中英

SQL query for JIRA database to find linked issues

I am trying to get information directly out of the Jira database. I want to programmatically find all issues that are linked to a particular issue (issue links such as "is developed by", "is continued by" etc.) I have a query which only returns one issue, when I know that there are 8 linked to the main one.

select i.pkey 
from jiraschema.jiraissue i
inner join jiraschema.issuelink il ON il.source = i.id
left outer join jiraschema.issuelinktype ilt ON ilt.id = il.linktype
where i.pkey = 'ISS-324'

Is there an easy correction to this SQL or is there a better way of querying which will return all linked issues?

A note: in JIRA v6 and later, the pkey column is deprecated and always null , you'll have to use the project and the issuenum columns.

In your SQL, you forgot to link back to the jiraissue table to actually get the linked issues.

Here, the query is for the ticket ABCD-1247, where the project ABCD has the ID of 10500 (you can join it from the table project ):

SELECT
  ILT.OUTWARD,
  LI.* -- linked
FROM
  JIRAISSUE I -- parent
INNER JOIN ISSUELINK IL
ON
  IL.SOURCE = I.ID
INNER JOIN ISSUELINKTYPE ILT
ON
  ILT.ID = IL.LINKTYPE
INNER JOIN JIRAISSUE LI -- linked
ON
  LI.ID = IL.DESTINATION
WHERE
  I.PROJECT  = 10500 AND
  I.ISSUENUM = 1247;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM