SELECT
(SELECT GROUP_CONCAT(code ORDER BY machine_id SEPARATOR ',')
FROM tbl_machine
WHERE FIND_IN_SET(tbl_machine.machine_id,GROUP_CONCAT(tbl_select_item.machine)) ) AS sel,
tbl_borrow_logs.`user`,
tbl_borrow_logs.fullname,
tbl_borrow_logs.log_id,
tbl_borrow_logs.depart,
tbl_select_item.amount,
tbl_borrow_logs.tel1,
tbl_borrow_logs.tel2,
tbl_borrow_logs.obj,
tbl_borrow_logs.logs_status,
tbl_borrow_logs.loan_by,
tbl_borrow_logs.approve_by,
tbl_borrow_logs.start_date,
tbl_borrow_logs.end_date,
tbl_borrow_logs.date_receive,
tbl_borrow_logs.date_return,
tbl_borrow_logs.place,
tbl_borrow_logs.signature_user,
tbl_borrow_logs.signature_admin,
tbl_borrow_logs.signature_super_admin,
tbl_borrow_logs.return_signature_user,
DATEDIFF(end_date, start_date) AS totalday,
DATE_FORMAT(start_date, '%d') AS thaidate,
DATE_FORMAT(start_date, '%Y') + 543 AS thaiyear,
DATE_FORMAT(start_date, '%H.%i') AS thaitime,
DATE_FORMAT(end_date, '%d') AS thaidate2,
DATE_FORMAT(end_date, '%Y') + 543 AS thaiyear2,
DATE_FORMAT(end_date, '%H.%i') AS thaitime2,
DATE_FORMAT(date_receive, '%d') AS thaidate3,
DATE_FORMAT(date_receive, '%Y') + 543 AS thaiyear3,
DATE_FORMAT(date_receive, '%H.%i') AS thaitime3,
DATE_FORMAT(date_return, '%d') AS thaidate4,
DATE_FORMAT(date_return, '%Y') + 543 AS thaiyear4,
DATE_FORMAT(date_return, '%H.%i') AS thaitime4,
tbl_select_item.machine
FROM
tbl_borrow_logs
INNER JOIN tbl_select_item ON tbl_borrow_logs.log_id = tbl_select_item.logs_id
WHERE
log_id = 1
GROUP BY
date_borrow