By default laravel 5.4 would select all (SELECT * ) if you haven't specific the column name you wanted to select, it causes error.
Solution 1
What you can do is add the column name caused error to your groupBy part:From :
$data = DB::table('table_a')->where('userid','=', Auth::user()->id)To
->where('species','!=', '')
->where('action','=', 'insert')
->join('table_b', 'table_b.index_id', '=', 'table_a.species')
->join('table_c', 'table_b.table_c', '=', 'table_c.name_id')
->groupBy('table_a.species')
->take(5)->orderBy('table_b.last_edit_timestamp', 'desc')->get();
$data = DB::table('table_a')->where('userid','=', Auth::user()->id)
->where('species','!=', '')
->where('action','=', 'insert')
->join('table_b', 'table_b.index_id', '=', 'table_a.species')
->join('table_c', 'table_b.table_c', '=', 'table_c.name_id') ->groupBy('table_a.species','table_b.last_edit_timestamp',"scientific_name","formatted_sciname")
->take(5)->orderBy('table_b.last_edit_timestamp', 'desc')
->select(["scientific_name","formatted_sciname","species"])
->get();
Solution 2
change default value of strict from true to false, in config/database.php at "mysql"'strict' => true
No comments :
Post a Comment