3

I want to help in following query:-

    $this->db->select('nbr.*, dm.dma, st.abbrev as state,unit.size_title as ad_size_title,unit_u.size_title as ad_unit_title,di.size_title as ad_di_title,color.title as color_title');
$this->db->from('default_new_buy_request as nbr');
$this->db->join('default_dmadata as dm', 'nbr.dma_id = dm.id', 'left');
$this->db->join('default_states as st', 'nbr.state_id = st.id', 'left');

The nbr.dma_id comes with multiple comma (',') separated values and is going to compared with all dm.id in default_dmadata, but here it just compare only one value with dm.id. In short I need a an explode() type functionality to compare each of value with second column.

Dan
  • 9,391
  • 5
  • 41
  • 73
  • shall I give the mysql? could u convert it Codeigniter?? – Punitha Subramani Sep 05 '14 at 13:37
  • 1
    Well, i just convert this query into codeigniter function, but still did't get the required output, as i mentioned before, the values that consisting the column dm.da_id are like this (1,3,6).But it shows an sql error to to mismatch query structure.But i am sure i have coded every thing on proper way. – Muhammad Sajid Sep 05 '14 at 14:50

1 Answers1

1

Can you try it?

Use If the values In comma

In MYSQL, try it with Codeigniter

LEFT JOIN default_dmadata dm ON FIND_IN_SET(dm.dma_id, dm.id)
Punitha Subramani
  • 1,467
  • 1
  • 8
  • 6
  • 1
    This is my codeigniter active record style query, $this->db->join('default_dmadata as dm', 'FIND_IN_SET(nbr.dma_id , dm.id)', 'left'); – Muhammad Sajid Sep 05 '14 at 14:51