[英]CodeIgniter join select as
我的數據庫中有 2 個表需要加入。 一張表是artikelen表,另一張是collecties表。 我目前有。
$this->db->select('*');
$this->db->from('collecties');
$this->db->join('artikelen', 'artikelen.collecties_id = collecties.id');
它給出了正確的結果,但所有的雙字段(集合有一個標題字段和 artikelen 有一個標題字段)將成為一個(它返回 artikelen.title 字段),我無法訪問另一個表的行( collectionies.title 字段)。
我從 artikelen 中選擇了 10 個字段,從 collections 中只選擇了 collectionies.title。
無需更換即可執行此操作的簡單方法是什么
$this->db->select('*');
所有 10 個字段都帶有 as 語句。
確保您的兩個表在您的加入條件上都有行,否則它將返回空值。 並修改選擇如下$this->db->select('artikelen.*,collecties.title as ctitle');
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.