• Community
  • Products
  • Jira Software
  • Questions
  • SQL Query to get issue id of all the issues with issue type as Defect, status as closed of a particular project and for a particular version in Jira 6.1

SQL Query to get issue id of all the issues with issue type as Defect, status as closed of a particular project and for a particular version in Jira 6.1

Rohan Kulkarni December 11, 2013

SQL Query to get issue id of all the issues with issue type as Defect, status as closed of a particular project and for a particular version in Jira 6.1

2 answers

0 votes
Bharadwaj Jannu
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 11, 2013

hello Rohan,

you said that pkey is completely removed but it is present along with issuenum. check once again.

Also it is safe to use JQL rather using SQL as Nic Suggested.

Rohan Kulkarni December 11, 2013

Hi Bharadwaj,

pkey exists, but it has null values for all the entries in the table.

Also the code has already been written and since we are planning to migrate to Jira 6.1 we are facing this problem. This is a small application which has been added to a plugin(created by my team) to fetch issue details and populate the values in an excel sheet. I just need an sql query with some modification that will give the issueid(ex:- JST-1041) of the issues with a particular fixed version value of a project.

0 votes
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
December 11, 2013

I'd do that in JQL in Jira, not SQL. It's easier to construct, faster, respects security, and you can save it as a filter which is dynamic, exportable, shareable and can be used as the basis for reports.

In JQL,

issuetype = Defect and status = closed and project = <xyz> and version = <123>

In SQL, you'll need to join issue to issuetype, nodeassociation, project and status to begin with...

Rohan Kulkarni December 11, 2013

Nic,

I have a query that'd do that in Jira 5.0.7 and the query goes -> "SELECT vname FROM projectversion, nodeassociation, jiraissue WHERE ASSOCIATION_TYPE = 'IssueFixVersion' AND SINK_NODE_ID = projectversion.id AND SOURCE_NODE_ID = jiraissue.id AND pkey like '"+pkey+"'"

Since, in Jira 6.1, pkey column in table jiraissue has been removed and a new column has been added "issuenum", I am facing this problem in my java code.

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
December 11, 2013

Two things spring to mind:

1. You should NOT be embedding SQL in Java code. Why are you not simply using a proper internal JQL call which will be faster, safer and would have continued to work fine after your upgrade?

(And seriously, consider moving to JQL, because it will work)

Suggest an answer

Log in or Sign up to answer