title: Join query with comma separated values in codeigniter
body: <p>I have a table structure like</p>
  
  <pre><code>Table Name : crm_mrdetails
  
       id | mr_name | me_email     | mr_mobile  | mr_doctor|
       -------------------------------------------------
       1  | John    |abc@gmail.com | 9876543210 | 1,2      |
  
      Table Name : crm_mr_doctor
  
      id | dr_name     | specialization| product |
      -------------------------------------------- 
      1  | Abhishek    | cordiologist  | 1,2     |
      2  | Krishnan    | Physician     |2,4,5    |
  
      Table Name: crm_product
  
      id | product_name | unit| pts |
      -------------------------------- 
     1  | Crocin       | 50  | 50  | 
     2  | Crocin2      | 60  | 100 | 
     3  | Crocin3      | 30  | 90  | 
     4  | Crocin4      | 70  | 80  | 
     5  | Crocin5      | 80  | 50  |
  </code></pre>
  
  <p>I need to get data from "crm_mrdetails" table and join table "crm_mr_doctor" and "crm_product" ,joining condition like </p>
  
  <pre><code>crm_mrdetails.mr_doctor = crm_mr_doctor.id 
  crm_mr_doctor.product = crm_product.id
  </code></pre>
  
  <p>But there is a comma separated values in column and i need output in below manner.</p>
  
  <p>Output:</p>
  
  <pre><code>Array
  (
      [0] =&gt; stdClass Object
          (
              [id] =&gt; 1
              [mr_name] =&gt; john
              [mr_email] =&gt; abc@gmail.com
              [mr_mobile] =&gt; 9876543210
              [doctor] =&gt;([0]=&gt;stdClass Object
                             (
                               [id] =&gt; 1
                               [dr_name] =&gt; Abhishek
                               [product] =&gt;([0]=&gt;stdClass Object
                                                (
                                                  [id] =&gt; 1
                                                  [product_name] =&gt; crocin
                                                  [unit] =&gt; 50
                                                  [pts] =&gt; 50
                                                )
                                             [1]=&gt;stdClass Object
                                                (
                                                  [id] =&gt; 2
                                                  [product_name] =&gt; crocin2
                                                  [unit] =&gt; 60
                                                  [pts] =&gt; 100
                                                ) 
                                           )
  
                              )
                           [1]=&gt;stdClass Object
                            (
                               [id] =&gt; 1
                               [dr_name] =&gt; Krishnan
                               [product] =&gt;([0]=&gt;stdClass Object
                                                (
                                                  [id] =&gt; 2
                                                  [product_name] =&gt; crocin2
                                                  [unit] =&gt; 60
                                                  [pts] =&gt; 100
                                                )
                                             [1]=&gt;stdClass Object
                                                (
                                                  [id] =&gt; 2
                                                  [product_name] =&gt; crocin4
                                                  [unit] =&gt; 70
                                                  [pts] =&gt; 80
                                                ) 
                                             [2]=&gt;stdClass Object
                                                (
                                                  [id] =&gt; 2
                                                  [product_name] =&gt; crocin5
                                                  [unit] =&gt; 80
                                                  [pts] =&gt; 50
                                                ) 
                                           )
  
                              )
                         )
           )
  )
  </code></pre>
  
  <p>I need to write query in codeigniter to get output like above Please help me to achieve this result, Thanks</p>