logo
down
shadow

Laravel Join Returning odd values


Laravel Join Returning odd values

By : Morfoot
Date : November 17 2020, 11:58 AM
To fix the issue you can do The problem is that you have multiple columns named userid. followers.userid and blogs.userid. Now in this case, unfortunately followers.userid gets returned when you use $build->userid
You can change that by only selecting the columns you want in your result.
code :
$userid = Auth::user()->id;
$query = DB::table('blogs')
  ->join('followers', function($q) use ($userid){
      $q->on('blogs.id', '=', 'followers.blogid');
      $q->where('followers.userid', '=', $userid);
  })
  ->select('blogs.userid', 'other-column')
  ->where('frontpage', '1')
  ->latest('lastupdated');


Share : facebook icon twitter icon
Full Outer Join not returning unmatched join field values SQL SERVER 2005

Full Outer Join not returning unmatched join field values SQL SERVER 2005


By : Nagachandra
Date : March 29 2020, 07:55 AM
hope this fix your issue All I had to do was change the first line of code to convert any null premium value to 0.
code :
SELECT   isnull(sept.eprem,0)-isnull(aug.eprem,0) as eprem , sept.coveragecode, zipcode 
from

(select 
SUM(EarnedPremium) AS eprem,coveragecode, evaluationdate, zipcode                       
FROM         dbo.StatRateSummary                            
where evaluationdate = '09-30-2011' 
and decpagetypecode != 'x'
GROUP BY evaluationdate ,coveragecode, zipcode

) as sept full outer join 

(select 
SUM(EarnedPremium) AS eprem,coveragecode, evaluationdate, zipcode                       
FROM         dbo.StatRateSummary                            
where evaluationdate = CONVERT(DATETIME, DATEADD(d,-1,DATEADD(mm, DATEDIFF(m,0,'09-30-2011'),0)), 102)  
and decpagetypecode != 'x'
GROUP BY evaluationdate ,coveragecode, zipcode

) as aug on sept.coveragecode = aug.coveragecode and sept.zipcode = aug.zipcode
where sept.coveragecode is not null and sept.coveragecode <> ''
order by coveragecode, sept.evaluationdate
Laravel Join Not Returning Specified Column

Laravel Join Not Returning Specified Column


By : WmFiske
Date : March 29 2020, 07:55 AM
it should still fix some issue After many hours, I found the solution. Using on in the join, I added a simple:
code :
->groupBy('jobs.id')
Laravel Eloquent not returning join table

Laravel Eloquent not returning join table


By : Илья Ивлев
Date : March 29 2020, 07:55 AM
Hope that helps I have the following function that joins 2 models. , whereHas doesn't load relations. You should use with for this. Try:
code :
   Game::where('status', '2')->whereHas('transaction', function ($query) use($id) {
    $query->where('status',1)->where('transaction_id', Crypt::decrypt($id));
})->with('transaction')->get()
Eloquent Query with Left join returning double the sum of the actual values in Laravel

Eloquent Query with Left join returning double the sum of the actual values in Laravel


By : Philipp N.
Date : March 29 2020, 07:55 AM
I wish did fix the issue. If you remove the grouping and SUMs then you can see all of the rows that are returned, and that your left joins are causing a duplication error:
code :
SELECT `bills`.`billId`, `bills`.`billDate`, `bills`.`billNumber`, `bills`.`billAmount`,
        deductions.deductionAmount,
        receipts.receiptAmount
FROM `bills` left join `receipts` on `receipts`.`billId` = `bills`.`billId`
             left join `deductions` on `deductions`.`billId` = `bills`.`billId`
WHERE `bills`.`workId` = 6
SELECT b.`billId`, b.`billDate`, b.`billNumber`, b.`billAmount`,
        (SELECT SUM(deductionAmount) FROM deductions WHERE BillID = b.BillId) as totalDeductions,
        (SELECT SUM(receiptAmount) FROM receipts WHERE BillID = b.BillId) as totalReceipts
FROM `bills` b
WHERE b.`workId` = 6
PSQL left outer join not returning values for unmatched join

PSQL left outer join not returning values for unmatched join


By : Igor Belousov
Date : March 29 2020, 07:55 AM
fixed the issue. Will look into that further This is too long for a comment. I suspect it is working correctly, but that the results are not in the order that you expect.
Does adding an order by bring all the dates in the order you want?
code :
select alldates.date as alldate,
       datadates.date as datadate
from alldates left outer join
     datadates
     using(date)
order by alldates.date;
Related Posts Related Posts :
  • how to run wordpress php snippet mysql update command from ssh and/ultimately cron
  • how to get xml tag by name
  • ModSecurity maximum post limits (PCRE limit errors)
  • Call controller/action in event listener
  • How to improve performance of contacting WebService?
  • PHP nest variable in echoed string that contains a HTML tag in the end
  • Multiple Ajax request for PHP framework
  • Debug Info from Moodle Plugin
  • passing variables through page
  • Passing PHP $result data to Javascript
  • cakePHP File Download was not found or not readable
  • batch waiting until script finishes
  • PHP variables and anchors in URL
  • php eTag generation using php
  • How to check whether the array is an Integer or Not?
  • Is it possible to install Doctrine without PEAR or Composer? If so, how?
  • Call view script of (parent) Abstract controller Zend
  • Curl PHP cannot display amazon
  • Symfony, getters and setters vs magic methods
  • Using 'continue' PHP instruction outside the loop
  • AJAX POST return data not appearing
  • Can I query relations using an INNER JOIN instead of two queries in Eloquent?
  • Looping through dynamic form fields and inserting into database
  • My php code can't select mysql auto_increment value
  • Store Angularjs form data in database using php
  • I want to run my sh file continuously even if I close my Putty connection
  • file_get_contents equivalent for gzipped files
  • Include PHP file with jQuery
  • php curl headers do not return from website?
  • How to find out, if facebook ID is a user, group or page
  • Connect webhost database to android database
  • preg_match get div content with class
  • Upload multiple files in Laravel 4
  • Count array numbers in multidimensional array
  • PHP Date diff with a difference
  • Search Customer by custom field in Netsuite
  • Is it possible to hide/encode/encrypt php source code and let others have the system?
  • list items to be displayed using php code and array
  • check if row exists mysqli
  • PHP errors loading MySQL
  • setup PostgreSQL with Laravel in MAMP
  • PHP - CodeIgniter Notifications
  • Encrypting a password column in a SQL database
  • New to PHP, trying to extract information from another website
  • JavaScript AmChart to Image for Email
  • Is javascript validation enough to keep my forms secure?
  • Regex extract variables from [shortcode]
  • Download a .mp3 link and save it to computer with PHP
  • Error with the ereg_replace
  • Getting the fields attached to a bundle of an entity in Drupal
  • Php how to check multiple times (within `foreach`) if values from array exists in mysql?
  • MySQL and PHP parsing strange string
  • Pull specific data from multidimensional associative array
  • How to get the original URI extension using PHP Tonic?
  • Upload videos and images from Android to PHP server?
  • Unset a multidimensional array with another multidimensional array with values than key
  • Calling a user e-mail to add to a mailto link PHP
  • Why is override_function coming back as an undefined function
  • PHP mySQLi_fetch_all: iterate through each row
  • Using pow in php
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org