TRUNCATE tbltenant_pdf_designs;

INSERT INTO tbltenant_pdf_designs (`uniquecode`, `tenant_id`, `type`, `pdf_designs_id`, `added_by`, `addedon`) SELECT LEFT(MD5(RAND() * t.id * pd.id), 32) as uniquecode, t.id as tenant_id, pd.type, pd.id as pdf_designs_id, 0 as added_by, NOW() as addedon FROM tbltenants t JOIN tblpdf_designs pd ON 1 = 1 AND pd.codename LIKE '%type_2%' ORDER BY t.id;