title: How do I decide when to use right joins/left joins or inner joins Or how to determine which table is on which side?
body: <p>I know the usage of joins, but sometimes I come across such a situation when I am not able to decide which <strong>join</strong> will be suitable, a <strong>left or right</strong>.</p>
  
  <p>Here is the query where I am stuck.</p>
  
  <pre><code>    SELECT  count(ImageId) as [IndividualRemaining],
                  userMaster.empName AS ID#,
                  CONVERT(DATETIME, folderDetails.folderName, 101) AS FolderDate,
                  batchDetails.batchName AS Batch#,
                  Client=@ClientName,
                  TotalInloaded = IsNull(@TotalInloaded,0),
                  PendingUnassigned = @PendingUnassigned,
                  InloadedAssigned =     IsNull(@TotalAssigned,0),
                  TotalProcessed = @TotalProcessed,
                  Remaining = @Remaining
          FROM
                  batchDetails
                      Left JOIN  folderDetails ON batchDetails.folderId = folderDetails.folderId
                      Left JOIN  imageDetails ON batchDetails.batchId = imageDetails.batchId
                      Left JOIN  userMaster ON imageDetails.assignedToUser = userMaster.userId
  
          WHERE   folderDetails.ClientId =@ClientID and verifyflag='n'
                  and folderDetails.FolderName IN (SELECT convert(VARCHAR,Value) FROM dbo.Split(@Output,','))
                  and userMaster.empName &lt;&gt; 'unused'
  
          GROUP BY userMaster.empName, folderDetails.folderName, batchDetails.batchName
  
          Order BY folderDetails.Foldername asc
  </code></pre>