DROP TABLE doc_changed_last_id;
CREATE TABLE doc_changed_last_id as 

SELECT doc_no,max(id) row_last_id FROM `user_activity` WHERE doc_no in (SELECT doc_no FROM `changed_docno_list` WHERE `updated` = 1) GROUP BY doc_no;


SELECT page_id voucher_id,page_name voucher_name,doc_no voucher_no,created_by,created_date,ip, input_data header_data,child_data,changes header_changes FROM `user_activity` WHERE id in (SELECT row_last_id FROM doc_changed_last_id);
