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 8413449
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T00:55:29+00:00 2026-06-10T00:55:29+00:00

I have inherited the following db and following query which extracts program names where

  • 0

I have inherited the following db and following query which extracts program names where those programs have subscribers.

SELECT DISTINCT label 
FROM program 
  WHERE EXISTS (
        SELECT occurrence.uuid
        FROM    booking
        INNER JOIN enrolment on enrolment.booking = booking.uuid
        INNER JOIN occurrence on occurrence.id = enrolment.occurrence 
        AND occurrence.programme = programme.uuid
        AND booking.status IN ('completed','booked')
      )

The following are simplified relevant tables.

Every program has a programType. I need to amend the above query to get the label from the ProgramType instead of the Program, for all booked programs.

**Program**

ID    UUID                                 Label     ProgramType  
---------------------------------------------------------------------------------
12    04FE546E-DD70-AAA3-2DB0DB3246790967  Prog1    8BA7E719-19B9-EFA7-D6937B42D3A4A056
32    04FE54FD-E8C5-9B02-2A08BBC22E630F09  Prog2    6EA6CB18-0E3F-360F-8BA8468E406C1EAB

**ProgramType**

ID                                   Label        
------------------------------------------
8BA7E719-19B9-EFA7-D6937B42D3A4A056  Type1  
6EA6CB18-0E3F-360F-8BA8468E406C1EAB  Type2  

**Booking**

UUID                                 Label           Occurrence  Status
------------------------------------------------------------------------
102B22F0-19B9-EFA7-D66E9E6746B5CC64  Booking1        73          Completed
C8930CB4-19B9-EFA7-D6A15045AFF02FA4  Booking2        15          Booked

**Occurrence**
(One program can have different dates etc)

ID    UUID                                 Program                              StartDate
-------------------------------------------------------------------------------------------
73    102B22F0-19B9-EFA7-D66E9E6746B5CC64  8BA7E719-19B9-EFA7-D6937B42D3A4A056  2010-11-05
15    C8930CB4-19B9-EFA7-D6A15045AFF02FA4  8BA7E719-19B9-EFA7-D6937B42D3A4A056  2010-11-12

**Enrolment**
(Fully enrolled once paid)

ID    UUID                                 Program                              PaymentID
-------------------------------------------------------------------------------------------
73    31D5680F-00EF-349C-E00F8A425EF531E3  31E84300-D8EB-4E9C-9CD8F87B47CABD84  100027
15    31E8543A-A810-DB22-C5EE25B8FF8BE3CA  31F2F89C-A88B-3B2C-53995F03C8276C5A  100029
  • 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-10T00:55:30+00:00Added an answer on June 10, 2026 at 12:55 am

    You can do this by adding a join to your query:

    SELECT DISTINCT ProgramType.label
    FROM program join
         programType
         on program.ProgramType = ProgramType.Id
    WHERE EXISTS (SELECT occurrence.uuid
                  FROM booking INNER JOIN
                       enrolment
                       on enrolment.booking = booking.uuid  INNER JOIN
                       occurrence
                       on occurrence.id = enrolment.occurrence AND
                          occurrence.programme = programme.uuid AND
                          booking.status IN ('completed','booked')
                 ) 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a query that looks like the following: SELECT * FROM table WHERE
I have the following query; classB inherits from classA classC is friend of classB
Code which I have inherited keeps crashing out rather powerfully with the following error
I have the following code (inherited from someone): <div class=feedback>&nbsp;</div> <form onsubmit=return false autocomplete=off>
Let's say I have the following class hierarchy: TaskViewer inherits from ListViewer<Task> which in
I currently have the following MySQL query, which I would like to include in
I have the following code in specman that I inherited: some_method() is { var
I have defined an Event class: Event and all the following classes inherit from
I have the following dependency property in my MainWindow class (inherits from WPF's Window)
I have the following two classes, one inherits from the other Class A{ void

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.