Jump to content

Query work with localhost and not work in live server


thara

Recommended Posts

Hi.. everyone!!

 

My this mysql query is working properly in localhost

 

$qry = "SELECT GROUP_CONCAT(subject.subjects SEPARATOR ', ') AS subjects
            FROM subject 
            INNER JOIN tutor_category_subject ON tutor_category_subject.subject_id = subject.subject_id 
            WHERE tutor_category_subject.tutor_id = $tutorId";

 

But it is uploaded to live server. it is not working and I can this error message.

 

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

 

can anybody tell me what has happen to this query?

 

Thank you

Link to comment
Share on other sites

your live server is running with the sql mode 'ONLY_FULL_GROUP_BY' enabled... probably running in ANSI mode if the mysql version is before 5.0.3

 

the error means that you are using an aggregate function (GROUP_CONCAT()) without a GROUP BY clause.

 

more to read here:

http://dev.mysql.com/doc/refman/5.0/en/group-by-functions.html

 

and here:

http://dev.mysql.com/doc/refman/5.0/en/server-sql-mode.html

Link to comment
Share on other sites

Thanks for response.

 

Sorry I have made a mistake in my last posted query. This is my real one which I am trying .

 

				$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";

Link to comment
Share on other sites

Yeah, I was going to say that there is noting wrong with that (first) query. If there are no non-Aggregate columns in the SELECT list, the aggregate runs across the entire result set.

 

With the second query you have a non-Aggregate column so you need a GROUP BY.

 

SELECT nameColumn, SUM(valueColumn)
FROM someTable
WHERE something = whatever
GROUP BY nameColumn;

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.