Ad
How To Make A Distinct In Only One Table Of A Join Using Laravel Query Builder?
I have this query... and I would like to make a distinct only in (tbl_holdings)
This is my query
$holdings = DB::table('tbl_perimetros')
->distinct()
->join('tbl_holdings', 'tbl_holdings.id', '=', 'tbl_perimetros.holdings_id')
->get();
Ad
Answer
Use groupBy
instead of distinct
:
$holdings = DB::table('tbl_perimetros')
->groupBy('tbl_perimetros.holdings_id')
->get();
Remove ONLY_FULL_GROUP_BY:
Add modes
to the config/database.php
'mysql' => [
...
'modes' => [
'STRICT_ALL_TABLES',
'ERROR_FOR_DIVISION_BY_ZERO',
'NO_ZERO_DATE',
'NO_ZERO_IN_DATE',
'NO_AUTO_CREATE_USER',
],
],
Ad
source: stackoverflow.com
Related Questions
- → "failed to open stream" error when executing "migrate:make"
- → October CMS Plugin Routes.php not registering
- → OctoberCMS Migrate Table
- → OctoberCMS Rain User plugin not working or redirecting
- → October CMS Custom Mail Layout
- → October CMS - How to correctly route
- → October CMS - Conditionally Load a Different Page
- → Make a Laravel collection into angular array (octobercms)
- → In OctoberCMS how do you find the hint path?
- → How to register middlewares in OctoberCMS plugin?
- → Validating fileupload(image Dimensions) in Backend Octobercms
- → OctoberCMS Fileupload completely destroys my backend
- → How do I call the value from another backed page form and use it on a component in OctoberCms
Ad