![](/img/trans.png)
[英]How to get min and max value from the same column at same time from database in codeigniter?
[英]How to get max value and its row at the same time?
在“專輯頭”表中,“專輯頭_圖片_id”是自動遞增的主鍵。 我正在嘗試獲取“ album_head_picture_id”的最大值以及針對該ID的整行。 什么是SQL? 我試過了
<?PHP $maximim_id=$this->db->query('SELECT MAX(album_head_picture_id) AS 'maxid' FROM album_head')->row()->maxid;?>
並使用該ID,再次...
<?PHP $query = $this->db->query("
SELECT * FROM album_head where album_head_picture_id= '.$maximim_id.'");
return $query->result();
?>
我正在嘗試在同一條sql中做到這一點。 任何想法? 提前致謝。
SELECT * FROM album_head where album_head_picture_id=(SELECT MAX(ID) FROM table)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.