Welcome Guest, Not a member yet? Register   Sign In
SQL SELECT CASE in codeigniter
#1

[eluser]Unknown[/eluser]
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.

Code:
<?php
        $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();
    ?>




Theme © iAndrew 2016 - Forum software by © MyBB