简体   繁体   中英

error query laravel 5.5

The query must generate Graduates by year of admission to the program and semester 1 or 2 of the year but I get the error:

SQLSTATE[42000]: Syntax error or access violation: 1055 'prueba_egresados.graduados.tipo_documento' isn't in GROUP BY(SQL: select * from 'graduados' group by 'anio_ingreso_programa','semestre_grado')

GraduadoController
public function reporteporanio() {
    $graduados =   graduado::groupBy('anio_ingreso_programa','semestre_grado')->get();
    return view('Consultas.grad_anio_semestre', ['graduados' => $graduados]);
}

vista reportes

 <html>
 <head>
    <meta charset="UTF-8">
    <title></title>
 </head>
 <body>
   <link href="{!!asset('css/bootstrap.min.css')!!}" rel="stylesheet">
  <a href="{{ url('/reportes_anio') }}" class="btn btn-info">Consulta por año y semestre</a>
 </body>
 </html>

grad_anio_semestre.php

@foreach($graduados as $graduado)
<tr>
<td>{{$graduado->numero_documento}}</td>
</tr>
@endforeach

i think wrong your code, groupby is name column. try this

$graduados = graduado::groupBy('anio_ingreso_programa')->get();
return view('Consultas.grad_anio_semestre', graduados);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM