I tried to take a string of data from the database by using substring but the results Unknown column 'code' in 'where clause'

Example my string **RS0002030720160003**

I want get **RS0002**

This my controllers

```
public function report(){
    $nomor = $this->input->post('nomor_reseller');

    $report_data = $this->hasil_m->get_data($nomor);
    if ($nomor == ""  ) {
        $this->session->set_flashdata('msg', 
                '<div class="alert alert-danger text-center">
                <a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
                Nomor atau bulan Harus di isi &nbsp;&nbsp;</div>');
        redirect('admin/hasil');        
    } elseif ($report_data == NULL  ) {
        $this->session->set_flashdata('msg', 
                '<div class="alert alert-danger text-center">
                <a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
                kosong &nbsp;&nbsp;</div>');
        redirect('admin/hasil');        
    } else {            
        $data=array('title'     =>'KOPKAR - Pelanggan',
                    'report_data'   => $this->hasil_m->get_data($nomor),
                    'isi'       =>'admin/hasil'
        );          
        $this->load->view('dashboard/wrapper',$data);   
    }       

}

```

This my views

```
   <table class="table table-hover table-striped">
        <thead>
        <tr>    
            <th><div align="center">No</th>
            <th class="text-center">Produk</th>
            <th class="text-center">Jumlah Produk Terjual</th>
            <th class="text-center"></th>
            <th class="text-center"></th>                   
            <th class="text-center">Rp.</th>
            <th class="text-center">Action</div></th>
        </tr>
        </thead>
        <tbody>

        <?php
            $no = 1;            
            foreach ($report_data as $row) {                    
            ?>
            <tr>
                <td><?php echo $no; ?></td>
                <td><?php echo $row->id_barcode; ?></td>
                <td><?php echo $row->jumlah; ?></td>
                <td class="fontCap text-center"><?php  ?></td>
                <td class="fontCap text-center"><?php  ?></td>
                <td><div align="center"></div></td>
                <td><div align="center">
                    <a href="#" title="delete" onclick="return confirm('Anda yakin ingin menghapus produk  dengan ID  pada database?');" class="btn btn-danger btn-xs"><i class="fa fa-trash-o"></i></a>
                    </div>
                </td>
                    <?php
                    $no++;

            }
                ?>
            </tr>
    </table>    

```

This my module

```
function get_data($nomor) {
    $this->db->select('SUBSTRING(id_barcode, 1, 7) as code', false);
    $this->db->from('tb_pelanggan');
    $this->db->where('code',$nomor);    
    $query = $this->db->get();
    if ($query->num_rows() > 0) {
        return $query->result();
        } else {
        return false;
    }
}

```