Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/60.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 代码点火器。查询将复制结果_Php_Mysql_Codeigniter - Fatal编程技术网

Php 代码点火器。查询将复制结果

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); 也许这个链接可以帮助你

我有两张桌子

预订单详情

这里预订单id和产品id是外键,可以有重复的值

收到预订单

在这里,预订单id和产品id是放弃键,可以有重复项

我想提供预订单id并获取所有相关数据

这是我的问题


它返回重复的数据。有人能指出我的错误甚至我的数据库设计吗。

在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);