[英]order group_by in codeigniter
i have a table 我有一张桌子
id typesignal close open cont
1 4 150 300 2
2 3 20 40 1
3 2 50 75 15
4 1 15.2 30.8 5
5 1 200 225 8
6 6 200 500 8
7 7 10 20 4
8 8 9 12 2
9 9 5 8 3
10 5 40 50 4
11 4 5 8 9
12 5 4 2 3
13 8 5 4 0
i want to display the last row of each kind from the typesignal
column. 我想显示来自
typesignal
列的每种类型的最后一行。
$this->db->group_by('typesignal');
$query = $this->db->get('signals');
but I need the last row that was create i use 但我需要我使用的最后一行
$this->db->group_by('typesignal');
$this->db->order_by("idSignal");
$query = $this->db->get('signals');
but its not working. 但它不起作用。
The expected output is: 13,12,11,9,8,7,6,5,3,2
预期输出为:
13,12,11,9,8,7,6,5,3,2
i use this query 我用这个查询
$this->db->group_by('typeSignal');
$this->db->select_max('idSignal');
$this->db->order_by("idSignal", "DESC");
$query = $this->db->get('signals');
return $query->result_array();
is working the secret is $this->db->select_max('idSignal'); 正在工作的秘密是$ this-> db-> select_max('idSignal');
Thanx for the help 感谢您的帮助
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.