So I am working on an existing system and I am trying to figure out how they have their mysql setup. They have a query setup like this 

```
    $this->db->select('nID, nAID');
    $this->db->where('bValid', 1);
    $this->db->where('nID', (int)$nID);
    $this->db->from('event');
    $this->db->group_by('nID, nAID');

    $query = $this->db->get();

```

And this query works great, however I need to setup a sub query. I have written the query in SQL and tested it to confirm that it works but I am having trouble figuring out how to translate it. Basically what I need is rather than grabbing from 'event' table I need to grab from a sub selection I make prior to this. How I imagine it will be. 

```
    $this->db->select('nID, nAID');
    $this->db->where('bValid', 1);
    $this->db->where('nID', (int)$nID);
    $this->db->from(
         $this->db->select('something, somethingelse');
         $this->db->where('something', 1);
         $this->db->get();  
    );
    $this->db->group_by('nID, nAID');

    $query = $this->db->get();

```