php – 如何在我的查询CODEIGNITER中使用DISTINCT

$q = $this->db->select('
             books.title,reserved_books.id,reserved_books.isbn,reserved_books.price,reserved_books.item_sold,reserved_books.date_sold,reserved_books.total_amount
            ')
        ->from('reserved_books')
        ->join('books','reserved_books.isbn= books.isbn')
        ->limit($limit,$offset);

我怎么能在我的查询中使用distinct?
reserved_books.isbn是唯一的.

试试下面:
$this->db->distinct();

但是,区别并不总是有效.你应该添加 – > group_by(“name_of_the_column_which_needs_to_be unique”);

$this->db->group_by('column_name');

相关文章

统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
前言 之前做了微信登录,所以总结一下微信授权登录并获取用户...
FastAdmin是我第一个接触的后台管理系统框架。FastAdmin是一...
之前公司需要一个内部的通讯软件,就叫我做一个。通讯软件嘛...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...