one_n00b one_n00b - 1 year ago 48
MySQL Question

Codeigniter Column 'idimport_database' in where clause is ambiguous

I'm having trouble when I want to display data using codeigniter, please help.
I attach the code.

Controller :

public function views($idimport_database)
$this->template->load('template','view_data', $data);

Model :

function detail_transaction($idimport_database){
$this->db->where('idimport_database', $idimport_database);
$this->db->join('tbl_transaksi', 'tbl_transaksi.idimport_database = tbl_import_database.idimport_database');
return $this->db->get();

Here result error :

Error Number: 1052
Column 'idimport_database' in where clause is ambiguous
SELECT * FROM `tbl_import_database` JOIN `tbl_transaksi` ON `tbl_transaksi`.`idimport_database` = `tbl_import_database`.`idimport_database` WHERE `idimport_database` = '41' Filename: C:/xampp/htdocs/apriori/system/database/DB_driver.php
Line Number: 691

Answer Source

The error means both tables (tbl_import_database and tbl_transaksi) have a column named idimport_database, and MySQL does not know which one you intend to use in your where statement.

Change the function in your model to include the table name:

$this->db->where('tbl_import_database.idimport_database', $idimport_database);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download