Php 代码点火器。查询将复制结果
我有两张桌子 预订单详情 这里预订单id和产品id是外键,可以有重复的值 收到预订单 在这里,预订单id和产品id是放弃键,可以有重复项 我想提供预订单id并获取所有相关数据 这是我的问题Php 代码点火器。查询将复制结果,php,mysql,codeigniter,Php,Mysql,Codeigniter,我有两张桌子 预订单详情 这里预订单id和产品id是外键,可以有重复的值 收到预订单 在这里,预订单id和产品id是放弃键,可以有重复项 我想提供预订单id并获取所有相关数据 这是我的问题 它返回重复的数据。有人能指出我的错误甚至我的数据库设计吗。在select查询中应用DISTINCT语句。 $this->db->选择“*”使用特定列 $this->db->select('DISTINCT(pre_order_id),other column name); 也许这个链接可以帮助你
它返回重复的数据。有人能指出我的错误甚至我的数据库设计吗。在select查询中应用DISTINCT语句。 $this->db->选择“*”使用特定列
$this->db->select('DISTINCT(pre_order_id),other column name);
也许这个链接可以帮助你使用group by,也许有帮助:$this->db->group bypre\U order\U id;
id pre_order_id product_id quantity_recieved
$this->db->select('*');
$this->db->from('pre_order_details');
$this->db->join('recieve_pre_order', 'recieve_pre_order.product_id = pre_order_details.product_id');
$this->db->where('pre_order_details.pre_order_id',$pre_order_id);
return $this->db->get();
$this->db->select('DISTINCT(pre_order_id),other column name);