我使用CodeIgniter访问我的Mysql数据库,并且我有两个带有列ID的表(新闻和事件)。我想我可以在使用'as'关键字之前(之后尝试)使用select作为NewsID返回News ID列,但它返回NewsID并且仍然覆盖ID列。以下是一些示例代码。CodeIgniter加入/覆盖问题
$this->db->join('News', 'News.ID = Events.NID', 'left');
$this->db->where('Events.ID', $ID);
$this->db->get('Events');
//tried this before and after the join and added to the condition
$this->db->select('*, News.ID as NewsID');
任何信息或想法都会非常有帮助。
咦试试?你想做什么?获取新闻ID?你期待什么结果? – dispake
我正在尝试在事件和新闻之间进行连接,并且我希望ID是“事件ID”列,但“新闻ID”列是NewsID。 – ars265
啊,更清楚了。 – dispake