gpt4 book ai didi

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

转载 作者:可可西里 更新时间:2023-11-01 12:40:59 25 4
gpt4 key购买 nike

$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 here?reserved_books.isbn 是独一无二的。

最佳答案

尝试以下:

$this->db->distinct();

但 Distinct 并不总是有效。您应该添加 ->group_by("name_of_the_column_which_needs_to_be unique");

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

关于php - 如何在我的查询 CODEIGNITER 中使用 DISTINCT,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19509805/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com