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

  • Home
  • SEARCH
  • 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 6794329
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:12:33+00:00 2026-05-26T18:12:33+00:00

After doing some joins and stuff I have table in the following format name

  • 0

After doing some joins and stuff I have table in the following format

  name    session_id   status 
    abc         1          null       
    xyz         2          11          
    jack        2          10
    zuck        1          10 
    paul        1          10 

I want my results to be grouped like this

 session_id   name+status                   
    1            abc:-1, zuck:10, paul:10
    2            xyz:11, jack:11 

So I used MySql group_concat in sql like

    SELECT sr.avail_id AS id,sr.student_id, sa1.punctuality_status as associate_punctuality_status, IF(
                    (sa.punctuality_status IS NULL),
                    (group_concat(u.firstname, ' ', u.lastname, ':', '-1'), 
                    (group_concat(u.firstname, ' ', u.lastname, ':', sa.punctuality_status)
                    ),
                    sr.tutor_id AS associate_id, FROM_UNIXTIME( sr.timestart ) AS timestart,  
                    sr.session_id AS session_id, sr.type AS session_type, p.name AS program_name,
             m.name AS module_name, ms.name AS session_name, sr.status as session_status FROM mdl_session_requests AS sr 
        LEFT JOIN mdl_session_attendee AS sa ON ( sr.student_id = sa.user_id AND sr.session_id = sa.session_id )  
        LEFT JOIN mdl_session_attendee AS sa1 ON (sr.tutor_id=sa1.user_id and sr.session_id=sa1.session_id)  
        INNER JOIN mdl_module_session ms ON ms.id = sr.course_id    
        INNER JOIN mdl_module m ON m.id = ms.module_id   
        INNER JOIN mdl_program p ON p.id = m.program_id   
        INNER JOIN mdl_user u ON u.id = sr.student_id    
        WHERE sr.tutor_id =438 group by avail_id order by sr.timestart desc

error = “#1064 – You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘AS associate_id, FROM_UNIXTIME( sr.timestart ) AS timestart, sr.session_id AS ‘ at line 6”

Is something wrong with this sql ?

  • 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-05-26T18:12:34+00:00Added an answer on May 26, 2026 at 6:12 pm
    SELECT 
         s.session_id AS id,
         group_concat(SEPARATOR ', ' CONCAT(u.firstname, ' ', u.lastname, ':',IF(s1.status IS NULL,'-1',s1.status))), sr.tutor_id
    
    FROM [a table]
    GROUP BY session_id
    

    Problems:

    1. No FORM clause
    2. parentesis where not matching
    3. GROUP_CONCAT can be done on one field, so you need to CONCAT() all the values first.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

After doing some work with Ruby, Rails, and RSpec last summer and I learned
After doing some research on the subject, I've been experimenting a lot with patterns
I'm getting a getaddress error and after doing some sleuthing, it looks like it
I want to convert a string into a double and after doing some math
I'm writing a wizard for an Eclipse RCP application. After doing some processing on
after doing some test-code for this link : Is it safe to call temporary
after doing some research it seems that AppDomains are not really a tool for
I've been doing some practice for my O/SCJP exam. Consider the following code: public
We have a table of transactions which is structured like the following : TranxID
After doing some asking around and reading, it sounds like you're lucky to get

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.