How to automatically fill up from two or multiple database tables and save new records to custom table