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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T06:16:55+00:00 2026-06-09T06:16:55+00:00

Everyone, this mysql query is working properly on localhost $query3 = SELECT tutor_category_subject.subject_id, GROUP_CONCAT(

  • 0

Everyone, this mysql query is working properly on localhost

                $query3 = "SELECT tutor_category_subject.subject_id, GROUP_CONCAT( DISTINCT subject.subjects SEPARATOR ', ') AS teaching_subjects  
                            FROM tutor_category_subject
                            INNER JOIN subject ON tutor_category_subject.subject_id = subject.subject_id
                            WHERE tutor_category_subject.tutor_id = $teacherId";

But on uploading it to the live server, it’s not working and I get this error message.

Mixing of GROUP columns (MIN(),MAX(),COUNT(),…) with no GROUP
columns is illegal if there is no GROUP BY clause

This is my query output without GROUP BY clause.

 +------------+-------------------------------+
| subject_id | teaching_subjects             |
+------------+-------------------------------+
|          8 | Art & Craft                   |
|         10 | Buddhism                      |
|         12 | Catholicism                   |
|         14 | Christianity                  |
|         16 | Dancing                       |
|         34 | Accounting                    |
|         37 | Business Studies              |
|         39 | Conbined Mathematics          |
|         42 | General Infomation Technology |
+------------+-------------------------------+

Can someone tell me what the problem might be?

Thank you

describe tables

mysql> describe tutor_category_subject;
+-------------+-----------------+------+-----+---------+----------------+
| Field       | Type            | Null | Key | Default | Extra          |
+-------------+-----------------+------+-----+---------+----------------+
| tcs_id      | int(4) unsigned | NO   | PRI | NULL    | auto_increment |
| tutor_id    | int(4) unsigned | NO   |     | NULL    |                |
| category_id | int(2) unsigned | NO   |     | NULL    |                |
| subject_id  | int(4) unsigned | NO   |     | NULL    |                |
+-------------+-----------------+------+-----+---------+----------------+

mysql> describe subject;
+------------+-----------------+------+-----+---------+----------------+
| Field      | Type            | Null | Key | Default | Extra          |
+------------+-----------------+------+-----+---------+----------------+
| subject_id | int(2) unsigned | NO   | PRI | NULL    | auto_increment |
| subjects   | varchar(60)     | NO   | MUL | NULL    |                |
+------------+-----------------+------+-----+---------+----------------+

I need to select subjects to a particular tutor. One tutor could have more subjects. thats why I used ‘GROUP_CONTACT()’ in my query. Without group by clause query is working in local host. But not in online.

  • 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-09T06:16:56+00:00Added an answer on June 9, 2026 at 6:16 am

    The error message tells you why that happens: You need a GROUP BY clause.

    It’s difficult to say what exactly you want to group on without knowing what the query should do and what your data is.

    I’m not sure whether I have understood correctly what you want, try whether this does the correct thing for you:

    SELECT s.subject_id, GROUP_CONCAT(DISTINCT s.subjects)
    FROM tutor_category_subject AS tcs
    INNER JOIN subject as s 
        ON tcs.subject_id = s.subject_id
    GROUP BY tcs.category_id
    WHERE tcs.tutor_id = $teacherId
    

    Pay attention to SQL injections for $teacherId

    As you can see, I have completely removed the GROUPing stuff. If your query yields a result, where you would like to combine multiple rows into one, that is when you need GROUP_BY my_column: merge those, that have an equal value in column my_column. Aggregate Functions are used to control how exactly the other columns are merged.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hay Everyone, i have a MySQL query SELECT * FROM `product` WHERE `price` BETWEEN
Sorry in advance everyone for this question as I know the cascading select boxes
everyone. I know this is a far treated subject, but I've looked everywhere and
This query appears in mysql slow query log: it takes 11 seconds. INSERT INTO
I'm using some crazy mixture of PHP/JavaScript/HTML/MySQL $query = SELECT * FROM faculty WHERE
I have this script : $limit1=10; $MySQL=mysql_connect($myhost,$myuser,$mypass); mysql_select_db($sitedb); $rank = mysql_query('SELECT usrid,num FROM 7stat
What I have is this: $SQL = SELECT * FROM users; $query = mysql_query($SQL)
Hi to everyone this is my first ask on stackoverflow I've created a simple
I think everyone knows this site http://pinterest.com/ and I don't want to create site
What is this 'Lambda' everyone keeps speaking of? A lot of people seem to

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.