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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T14:51:26+00:00 2026-06-11T14:51:26+00:00

Here’s a picture of my database structure: With help from users on here I’ve

  • 0

Here’s a picture of my database structure:

Observation recording - database structure

With help from users on here I’ve managed to put together quite a complex SQL statement using GROUP_CONCAT:

SELECT
     t1.Name AS Teacher_Name,
     t2.Name AS Observer_Name,
     o.Datetime AS Datetime,
     o.Type AS Type,
     o.Year_Group AS Year_Group,
     o.Class_Name AS Class_Name,
     c.Title AS Course_Name,
     GROUP_CONCAT(l.Title) AS Focus,
     o.Achievement_Grade AS Achievement_Grade,
     o.Behaviour_Grade AS Behaviour_Grade,
     o.Teaching_Grade AS Teaching_Grade,
     GROUP_CONCAT(cl1.Title) AS Positive,
     GROUP_CONCAT(cl2.title) AS Development,
     o.Notes AS Notes
FROM observations o
LEFT JOIN teachers t1 
    ON o.Teacher_ID = t1.Teacher_ID
LEFT JOIN teachers t2 
    ON o.Observer_ID = t2.Teacher_ID
LEFT JOIN courses c 
    ON o.Course_ID = c.Course_ID
LEFT JOIN  foci f
    ON o.ID = f.Observation_ID
LEFT JOIN focus_labels l
    on f.focus_id = l.id
LEFT JOIN  criteria c1
    ON o.ID = c1.Observation_ID
LEFT JOIN criteria_labels cl1
    on c1.Criteria_ID = cl1.ID AND c1.Type = 'P'
LEFT JOIN  criteria c2
    ON o.ID = c2.Observation_ID AND c2.Type = 'D'
LEFT JOIN criteria_labels cl2
    on c2.Criteria_ID = cl2.ID
GROUP BY o.id
ORDER BY `Datetime` DESC";

This appears to work OK, apart from the fact that Focus, Positive and Development are each repeated depending on the field that has the highest number of concatenations in.

For example, if Positive has Pace,Progress,Attainment but Focus is only Appraisal, it’ll be repeated three times (Appraisal,Appraisal,Appraisal).

Observation Recording - Complex join structure

I’ve looked this up and I think it could be because I need to GROUP each of these GROUP_CONCAT JOINs. However, I have no idea how to go about this.

Can anyone help? Thanks in advance,

  • 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-11T14:51:27+00:00Added an answer on June 11, 2026 at 2:51 pm

    GROUP_CONCAT has DISTINCT attribute that can be applied to remove duplicates.

    SELECT
         t1.Name AS Teacher_Name,
         t2.Name AS Observer_Name,
         o.Datetime AS Datetime,
         o.Type AS Type,
         o.Year_Group AS Year_Group,
         o.Class_Name AS Class_Name,
         c.Title AS Course_Name,
         GROUP_CONCAT(DISTINCT l.Title) AS Focus,
         o.Achievement_Grade AS Achievement_Grade,
         o.Behaviour_Grade AS Behaviour_Grade,
         o.Teaching_Grade AS Teaching_Grade,
         GROUP_CONCAT(cl1.Title) AS Positive,
         GROUP_CONCAT(cl2.title) AS Development,
         o.Notes AS Notes
    FROM observations o
    LEFT JOIN teachers t1 
        ON o.Teacher_ID = t1.Teacher_ID
    LEFT JOIN teachers t2 
        ON o.Observer_ID = t2.Teacher_ID
    LEFT JOIN courses c 
        ON o.Course_ID = c.Course_ID
    LEFT JOIN  foci f
        ON o.ID = f.Observation_ID
    LEFT JOIN focus_labels l
        on f.focus_id = l.id
    LEFT JOIN  criteria c1
        ON o.ID = c1.Observation_ID
    LEFT JOIN criteria_labels cl1
        on c1.Criteria_ID = cl1.ID AND c1.Type = 'P'
    LEFT JOIN  criteria c2
        ON o.ID = c2.Observation_ID AND c2.Type = 'D'
    LEFT JOIN criteria_labels cl2
        on c2.Criteria_ID = cl2.ID
    GROUP BY o.id
    ORDER BY `Datetime` DESC";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is the script I'm using, copied directly from Google: <script type=text/javascript> var _gaq
Here is my SQL script CREATE TABLE tracks( track_id int NOT NULL AUTO_INCREMENT, account_id
Here's a piece of code I copied from http://www.schillmania.com/content/projects/javascript-animation-1/demo/ Very simple JS animation: function
Here is my error(if you need any more info just ask)- Error SQL query:
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
Here's a basic regex technique that I've never managed to remember. Let's say I'm
Here is a simplification of my database: Table: Property Fields: ID, Address Table: Quote
Here is the code from my project where I am using a datepicker. The
Here I am trying to retrieve the response from the server and display it,
Here is my simplified data structure: Object1.h template <class T> class Object1 { private:

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.