Left join with unique values
<p>I am looking to get all values from first table along with joinned values from second table.</p>

<p>Table 1 is fee_category with fields:</p>

<pre><code>id | Category
1  | A
2  | B
3  | C
4  | D
</code></pre>

<p>Table 2 is fee_charge with fields:</p>

<pre><code>id | std_id | particularID | CategoryID | assign | amount
1  | 1      | 1            | 1          | 0      | 1000  
2  | 1      | 1            | 2          | 1      | 12000  
3  | 1      | 2            | 3          | 0      | 3000  
4  | 1      | 2            | 4          | 0      | 10  
5  | 2      | 1            | 2          | 0      | 100  
6  | 2      | 2            | 3          | 0      | 120  
</code></pre>

<p>Base table is "fee_category" from which I need all values left joining with "fee_charge" from where I need values or NULL for a particular std_id and particularID</p>

<pre><code>SELECT fee_category.id, fee_category.Category, fee_charge.std_id
, fee_charge.particularID, fee_charge.CategoryID, fee_charge.assign, fee_charge.amount FROM fee_category
LEFT join fee_charge on fee_category.id=fee_charge.CategoryID
where (fee_charge.std_id = 1 OR fee_charge.std_id IS NULL) 
AND (fee_charge.particularID = 1 OR fee_charge.particularID IS NULL) 
group By fee_category.id
order By fee_charge.assign DESC
</code></pre>

<p>Here I am trying to get all categories of std_id=1 and particularID=1</p>

<p>Correct result should be</p>

<pre><code>id | Category | std_id | particularID | CategoryID | assign | amount
1  | A         | 1      | 1            | 1          | 0      | 1000
1  | B         | 1      | 1            | 2          | 1      | 12000
1  | C         | 1      | NULL         | NULL       | NULL   | NULL
1  | D         | 1      | NULL         | NULL       | NULL   | NULL
</code></pre>

<p>I am trying various versions of the above query but not getting proper result. Please help</p>