# 1055 - Expression # 1 of SELECT list is not in GROUP BY clause and contains nonaggregated column

0

I have the following query:

SELECT DISTINCT
pedidos.id,
pedidos.correlativo,
pedidos.tipo_trat,
pedidos.nombres,
pedidos.apellidos,
pedidos.estado,
pedidos.token,
etapas.estado_etapa,
etapas.etapa,
hijos.opcion,

(SELECT COUNT(*) FROM etapas WHERE folio = pedidos.correlativo)
AS num_etapas

FROM pedidos
INNER JOIN etapas ON (pedidos.correlativo = etapas.folio)
INNER JOIN hijos ON hijos.id = pedidos.tratamiento

WHERE pedidos.tipo_trat = 2 and pedidos.cliente = '$id_us' and pedidos.correlativo = etapas.folio and pedidos.estado = 'S' GROUP BY etapas.folio

where $ id_us is the id of the user that is taken from the SESSION.

When generating this query, I get the error:

1055 - Expression # 1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'mhenriqu_redmolar.pedidos.id' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode = only_full_group_by

I have tried different ways and possible solutions, but I have not managed to solve the problem and I do not want to disable the ONLY_FULL_GROUP_BY since I read that it is not the solution to the problem. Can someone help me with this error or how can I solve it? Thank you very much everyone.

    
asked by maha1982 05.11.2018 в 18:37
source

0 answers