p2.connector_brand_name, p2.element_brand_name, p4.item_code, p4.k1_e_status from pz_k1_e12_item p1 left join pz_k1_e07_item p2 on p1.e07_id = p2.id left join pz_k1_e07 p3 on p2.harness_id = p3.id left join pz_k1_e02 p4 on p4.id = p1.e02_id where p3.vehicle_code='SX11AD-2021' GROUP BY p2.element_brand_name,p2.connector_code > 1055 - Expression #4 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'edds.p3.harness_name' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by > 时间: 0.005s
时间: 2024-01-18 09:03:49 浏览: 397
根据你提供的 SQL 语句,错误信息显示在第 1 行,在 SELECT 子句中查询了一个未加入 GROUP BY 子句的列 p3.harness_name,需要修改。此外,你的 MySQL 数据库设置了 sql_mode=only_full_group_by,表示只有在 SELECT 语句中的列名都出现在 GROUP BY 子句中时,才能执行查询,因此还需要修改查询语句。如果你想查询 p2.connector_brand_name、p2.element_brand_name、p4.item_code 和 p4.k1_e_status 列,可以将它们加入 SELECT 子句和 GROUP BY 子句中,如下所示:
```
SELECT p2.connector_brand_name, p2.element_brand_name, p4.item_code, p4.k1_e_status
FROM pz_k1_e12_item p1
LEFT JOIN pz_k1_e07_item p2 ON p1.e07_id = p2.id
LEFT JOIN pz_k1_e07 p3 ON p2.harness_id = p3.id
LEFT JOIN pz_k1_e02 p4 ON p4.id = p1.e02_id
WHERE p3.vehicle_code='SX11AD-2021'
GROUP BY p2.connector_brand_name, p2.element_brand_name, p4.item_code, p4.k1_e_status;
```
这样就可以查询到 p2.connector_brand_name、p2.element_brand_name、p4.item_code 和 p4.k1_e_status 列,并且不会有 GROUP BY 子句的错误了。
阅读全文