Welcome Guest, Not a member yet? Register   Sign In
distinct problem
#1

[eluser]Bigil Michael[/eluser]
is it possible to list the distinct names from 3 columns of the same table?????

can anyone help me???? urgent

thanks in advance....
#2

[eluser]Rok Biderman[/eluser]
Distinct normally doesn't work that way, but it' s easy to run 3 separate queries in the model function and then assign all 3 arrays to result.
#3

[eluser]Bigil Michael[/eluser]
can u help me

these are the three columns
Code:
id  tour_type1  tourtype2  tourtype3
1      A          B           C
2      B          C           D
3      D          E           F

i want to list the distinct values that is
A
B
C
D
E
F
how will i do this can u help me??
thanks in advance.
#4

[eluser]Rok Biderman[/eluser]
Now, i'm sure that there are a more elegant ways to do this, but this one works as well.

Code:
function oneatatime($args)
    {
        
        $this->db->distinct();
        $this->db->select($args);
        $query = $this->db->get('narocniki');
        return $query->result();
    }

function alldatainsinglearray()
    {
        $myarray = array();
        $tour_type1 = ($this->oneatatime('tour_type1'));
        foreach ($tour_type1 as $item):
        array_push($myarray, $item->tour_type1);
            endforeach;
        $tour_type2 = ($this->oneatatime('tour_type2'));
        foreach ($tour_type2 as $item):
        array_push($myarray, $item->tour_type2);
            endforeach;
        $tour_type3 = ($this->oneatatime('tour_type3'));
        foreach ($tour_type3 as $item):
        array_push($myarray, $item->tour_type3);
            endforeach;
        return $myarray;
    }

Hope it helps.




Theme © iAndrew 2016 - Forum software by © MyBB