大家,这个mysql查询在本地主机上正常工作
$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";
但是在将其上传到实时服务器时,它无法正常工作,并且我收到此错误消息。
如果没有 GROUP BY 子句,则混合没有 GROUP 列的 GROUP 列 (MIN(),MAX(),COUNT(),...) 是非法的
这是我没有 GROUP BY 子句的查询输出。
+------------+-------------------------------+
| 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 |
+------------+-------------------------------+
有人可以告诉我可能是什么问题吗?
谢谢
描述表格
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 | |
+------------+-----------------+------+-----+---------+----------------+
我需要为特定的导师选择科目。一位导师可以有更多的科目。这就是我在查询中使用“GROUP_CONTACT()”的原因。没有 group by 子句查询在本地主机上工作。但不是在网上。