Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8936297
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T10:11:13+00:00 2026-06-15T10:11:13+00:00

I try to create a MySQL Statement with multiple SQL Statements. What i trying

  • 0

I try to create a MySQL Statement with multiple SQL Statements.

What i trying to do:
I get two tables, project & jiraissue.

Table: project

Columns:
ID  decimal(18,0) PK 
pname   varchar(255) 
URL varchar(255) 
LEAD    varchar(255) 
DESCRIPTION text 
pkey    varchar(255) 
pcounter    decimal(18,0) 
ASSIGNEETYPE    decimal(18,0) 

Table: jiraissue

Columns:
ID  decimal(18,0) PK 
pkey    varchar(255) 
PROJECT decimal(18,0) 
REPORTER    varchar(255) 
ASSIGNEE    varchar(255) 
issuetype   varchar(255) 
SUMMARY varchar(255) 
DESCRIPTION longtext 
ENVIRONMENT longtext 
PRIORITY    varchar(255) 
RESOLUTION  varchar(255) 
issuestatus varchar(255) 
CREATED datetime 
UPDATED datetime 
DUEDATE datetime 
VOTES   decimal(18,0) 
TIMEORIGINALESTIMATE    decimal(18,0) 
TIMEESTIMATE    decimal(18,0) 
TIMESPENT   decimal(18,0) 
WORKFLOW_ID decimal(18,0) 
SECURITY    decimal(18,0) 
FIXFOR  decimal(18,0) 
COMPONENT   decimal(18,0) 

My goal is to get the names of the projects (project.pname) which newest issue is updated before 2012 (jiraissue.UPDATED).

Example:
I get a Project ABC which newest issue was update in 21.11.2012. The other Project XYZ‘s newest issue was updated last in 08.12.2011.
So my SQL Script should give me the name of the second project XYZ but not the first ABC

A working script to find out which issue is the newest with a STATIC project ID comes here:

SELECT 
    pkey
FROM
    jiraissue
WHERE
    UPDATED = (SELECT 
            max(UPDATED)
        FROM
            jiraissue
        WHERE
            PROJECT = 10472)

But how is the script now, when i want the project names of ALL these projects? All of my trys take a lot of processing time and give a undefinied error back…

EDIT:
Now i get the following code:

select 
    p.pname, j.pkey
from
    project p
        inner join
    jiraissue j ON j.ID = (select 
            PROJECT
        from
            jiraissue
        where
            UPDATED = (SELECT 
                    max(UPDATED)
                from
                    jiraissue))
        AND p.ID = j.PROJECT

The Result is but just the first project with the lowest key… How can i browse ALL Projects?

EDIT:

select 
    p.pname, j.pkey, j.UPDATED
from
    project p
        inner join
    jiraissue j
where
    j.ID = (select 
            PROJECT
        from
            jiraissue
        where
            UPDATED = (SELECT 
                    max(UPDATED)
                from
                    jiraissue
                where
                    UPDATED < '2012-01-01 00:00:00'))
        and p.ID = j.PROJECT

It displays all what i want. But just the first project. So i need ALL projects!! How can i select not just 1 project but all projects?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T10:11:15+00:00Added an answer on June 15, 2026 at 10:11 am

    Start by first WHAT do you want. On a per project basis, what is the latest issue that was updated BEFORE 2012. Ignore the project table at the moment..

    select
          JI.Project,
          MAX( JI.Updated ) as LastUpdated
       from
          JiraIssue JI
       group by
          JI.Project
       having 
          LastUpdated < '2012-01-01'
    

    Now, this will give you all your primary information that you want. The HAVING clause is applied AFTER the group by to exclude any projects that are 2012 and future. You can’t apply it as the WHERE clause as your sample described you didn’t want anything that had a current (such as your ABC project) and only wanted the XYZ project.

    Use this as a basis for getting the rest of your data by joining to the project table and joining AGAIN back to the JiraIssue table by that project/update combination

    select
          P.*,
          JI2.*
       from
          ( select
                  JI.Project,
                  MAX( JI.Updated ) as LastUpdated
               from
                  JiraIssue JI
               group by
                  JI.Project
               having 
                  LastUpdated < '2012-01-01' ) PreQuery
    
             JOIN Project P
                on PreQuery.Project = P.ID
    
             JOIN JiraIssue JI2
                on PreQuery.Project = JI2.Project
               AND PreQuery.LastUpdated = JI2.Updated
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I get an error when I try to create a table in mysql. Any
I'm trying to create a new MySQL from a SELECT statement: CREATE TABLE site_database
Everytime I try to create the following table in MySQL command line: CREATE TABLE
I'm running MySQL 5.5.9 and InnoDB. I try to create a versioned table, where
I'm trying to create a prepared statement in MySQL that takes in a single
I'm trying to execute a basic INSERT statement on a MySQL table from a
When I try to run this statement: CREATE TABLE 'score_table' ( 'name' text NOT
I'm having an issue with MySQL and PHP. When I try to create a
I am trying to create a PDO class and I get the error: PHP
This is a simple program where i create two tables in a database using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.