Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

sadalsuud's avatar

how I do a this query

I try many forms that to make this query:

SELECT r.id, t.nombre, sum(cantidad), t.precio 
FROM alistamiento a, renglon r, renglon_trabajo rt, trabajo t 
WHERE a.fecha BETWEEN '2018-04-01' AND '2018-04-30' AND 
    a.id = r.alistamiento_id AND 
    r.id = rt.renglon_id AND 
    rt.trabajo_id = t.id AND 
    t.centro_id = 4 GROUP by t.id`

But Laravel send me this error:

SQLSTATE[42000]: Syntax error or access violation: 1055 'u162268723_picma.t.precio' isn't in GROUP BY (SQL: SELECT r.id, t.nombre, sum(cantidad), t.precio FROM alistamiento a, renglon r, renglon_trabajo rt, trabajo t WHERE a.fecha BETWEEN '2018-04-01' AND '2018-04-30' AND a.id = r.alistamiento_id AND r.id = rt.renglon_id AND rt.trabajo_id = t.id AND t.centro_id = 4 GROUP by t.id, r.id, t.nombre)

Finally I group by all columns together, but the query repeat rows...

Someone who can help me :|

0 likes
3 replies
jlrdw's avatar

Please enclose code between 3 backticks.

jlrdw's avatar

In-database config try changing strict mode to false.

1 like

Please or to participate in this conversation.