我正在使用Codeigniter从Firebird数据库获取记录:
$columns = [
'job.JOBID AS Id', 'job.ORDERID AS orderID', 'suburb.LONGITUDE AS Longitude', 'suburb.LATITUDE AS Latitude', 'suburb.LCNAME', 'address.TOWN', ];
$this->db->select($columns);
$this->db->from('WORK as job');
$this->db->join('CUSTOMER AS customer', 'customer.CUSTOMERID = job.CUSOMERTID', 'INNER');
$this->db->join('SALEORDER AS sorder', 'sorder.ORDERID = job.ORDERID', 'INNER');
$this->db->join('CUSTADDRESS AS address', 'address.ADDRID = sorder.DELADDRID', 'INNER');
$this->db->join('WORK2 AS job2', 'job2.JOBID = job.JOBID', 'LEFT');
// THE BELOW LINE CAUSE ERROR DUE TO LOWER
$this->db->join('SUBURBS AS suburb', 'suburb.LCNAME = LOWER(address.TOWN)', 'LEFT');
$query = $this->db->get();
代码在没有LOWER
的情况下正常运行,相关的JOIN
在没有它的情况下无效,因为条件为false。我已经说过,suburb.LCNAME = 'blacktown'
和address.Town = BlackTown
。
我收到以下错误消息,
遇到PHP错误 严重性:警告
消息:ibase_query():动态SQL错误SQL错误代码= -206列未知ADDRESS.TOWN在第12行第1列 文件名:ibase / ibase_driver.php
行号:129
答案 0 :(得分:1)
删除别名地址并使用以下行中的原始表名以及代码。 $ this-> db-> join(' CUSTADDRESS AS地址',' address.ADDRID = sorder.DELADDRID',' INNER');
使用相反: $ this-> db-> join(' CUSTADDRESS',' CUSTADDRESS.ADDRID = sorder.DELADDRID',' INNER');
答案 1 :(得分:0)
试试这个
$this->db->select($columns.',LOWER(address.Town) as lower_address');
$this->db->from('WORK as job');
$this->db->join('CUSTOMER AS customer', 'customer.CUSTOMERID = job.CUSOMERTID', 'INNER');
$this->db->join('SALERDER AS sorder', 'sorder.ORDERID = job.ORDERID', 'INNER');
$this->db->join('CUSTADDRESS AS address', 'address.ADDRID = sorder.DELADDRID', 'INNER');
$this->db->join('WORK2 AS job2', 'job2.JOBID = job.JOBID', 'LEFT');
// THE BELOW LINE CAUSE ERROR DUE TO LOWER
$this->db->join('SUBURBS AS suburb', 'suburb.LCNAME = lower_address', 'LEFT');
$query = $this->db->get();