CodeIgniter Forums

Full Version: SQL SELECT CASE in codeigniter
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

I have the below query but I need to only select field_id_3 and field_id_4 if channel_id is 2, otherwise select field_id_9 and field_id_10

I've just started out doing sql queries with codeigniter so not sure how you would do a CASE SELECT with it.

        $this->EE->db->select('entry_id, channel_id, field_id_3, field_id_4, field_id_9, field_id_10', FALSE);
        $this->EE->db->from('exp_channel_data AS cd');
        $this->EE->db->where('entry_id', '{entry_id}');
        $query = $this->EE->db->get();