I have a table:
and I want to display it like this one
id_pasien kunjungan
193 2018-02-23
193 2018-02-24
I've made this code but I don't know how to group it by timedate and display it like what I want above
public function record_Odontogram($id_pasiens){
$query = "SELECT id_pasien,
GROUP_CONCAT(inserted_at) as kunjungan
FROM odontogram WHERE id_pasien=$id_pasien AND YourDate >= dateadd(day,datediff(day,1,GETDATE()),0)
AND YourDate < dateadd(day,datediff(day,0,GETDATE()),0) ";
$res = $this->db->query($query);
return $res;
}
Inorder to group by date, use DATE():
$query = "SELECT id_pasien, DATE(inserted_at) as kunjungan
FROM odontogram
WHERE ...
GROUP BY DATE(inserted_at) ";
Use below Query
SELECT id_pasien, DATE_FORMAT(inserted_at, '%Y-%m-%d') as kunjungan FROM odontogram WHERE id_pasien=193 group by kunjungan asc
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.