从Codeigniter中的数据库获取数据时复制数据

时间:2019-06-14 07:26:14

标签: mysql codeigniter-3

我的代码返回重复数据。请帮助我。

我有3张桌子:

住宿表

------------ --------------
fldProductID fldProductID
------------ --------------
1              6
2              6

AccommodationText表

---------------------- ------------- -------------------
fldAccommodationTextID fldProductID fldAccommodationText
---------------------- ------------- -------------------
1                       6             text 1
2                       6             text 2
3                       10            text 4
4                       11            text 8

产品表

------------ --------
fldProductID seo_url
------------ --------
6           next_1
7           next_2

这是我的查询

$this->db->select('seo_url, Accommodation.fldProductID, fldAccommodationTextID');
$this->db->where('fldAccommodationDelete', '0');  
$this->db->where('seo_url', '6');
$this->db->from('Accommodation');
$this->db->join('Product', 'Product.fldProductID =  Accommodation.fldProductID', 'left');
$this->db->join('AccommodationText', 'AccommodationText.fldProductID = Accommodation.fldProductID');
$query = $this->db->get(); 
echo '<pre>'; 
var_dump($query->result()); 
echo'</pre>'; 
die;

0 个答案:

没有答案