01.
SELECT
*
FROM
asset
AS
t1
02.
LEFT
JOIN
(
SELECT
b.ast_id,a.trn_remark ,a.trn_status
03.
FROM
asset_transfer_head a
04.
INNER
JOIN
(
05.
SELECT
ast_id,
MAX
(trn_move_dt)trn_move_dt, trn_id
06.
FROM
asset_transfer_detail
07.
GROUP
BY
ast_id
08.
) b
ON
a.trn_id = b.trn_id
09.
AND
b.trn_move_dt=b.trn_move_dt
10.
AND
a.trn_status =
'1'
// พอเป็น Status 0,2,3,4 กลายเป็นไม่แสดง Remark ก่อนหน้านั้นด้วย
11.
)
as
p
ON
t1.asset_id = p.ast_id
12.
where
t1.status_gotoadmin=0
13.
ORDER
BY
t1.asset_id
DESC
LIMIT $start, $per_page";