我有两个表,第一个叫做latestnews,第二个叫做language_latestnews
latestnews
有`latestnewsstatus和latestnewsid。
和language_latestnews有latestnewsid
我需要显示唯一的Active latestnewsstatus,这是我在api中的代码
public function getlatest($select_values = "*", $table_name, $join_on = "", $language_id) {
$join_table = "language_" . $table_name;
$result = array();
$this->db->select($select_values);
$this->db->from($table_name);
if ($table_name != "latestnews") {
$this->db->where($table_name . ".featuredstatus","=", "Yes" );
}
$this->db->join($join_table, $table_name . "." . $join_on . "=" . $join_table . "." . $join_on, "left");
$this->db->where($join_table . ".languageid", $language_id ,'latestnews.latestnewsstatus',"=","Active");
$this->db->join('language_latestnews', 'language_latestnews.latestnewsid = latestnews.latestnewsid', 'left');
$this->db->where('latestnewsid.latestnewsstatus', "Active");
$this->db->limit("1");
$result = $this->db->get()->result_array();
return $result;
}
但它给了我数据库错误。你能告诉我这里有什么问题:(
错误是:
发生数据库错误
错误号码:1054
'where子句'中的未知列'latestnewsid.latestnewsstatus'
SELECT
offers
。offerid
,offertitle
来自offers
LEFT JOINlanguage_offers
点击offers
。offerid
=language_offers
。offerid
LEFT JOINlanguage_latestnews
点击language_latestnews
。latestnewsid
=latestnews
。latestnewsid
在哪里offers
。featuredstatus
='=' 和language_offers
。languageid
='1' 和latestnewsid
。latestnewsstatus
='有效' 限制1文件名:modules / api / models / Apimodel.php
行号:394
答案 0 :(得分:0)
错误是不言自明的'where子句'中的未知列'latestnewsid.latestnewsstatus'。在您的查询中,latestnewsstatus
表中没有名称为latestnewsid
的列。因此,请在此处输入正确的列名,然后重试。