If the order of the fields is identical, then everything is done in one request.
INSERT INTO data SELECT * FROM data_tmp
but it is not strongly recommended to do so, because when changing the order of the fields, you will have porridge without any messages.
What is the problem to get a list of fields (at least to score), and then create a query
$fields = 'fld1, fld2, fldn'; $sql = sprintf('INSERT INTO data (%s) SELECT %s FROM data_tmp', $fields, $fields);
Or execute the query
SELECT * FROM data_tmp
and then, based on mysqli_stmt_result_metadata, find out the field names and form an INSERT request?
UPDATE
If you need to update the records, then you need to add the construction ON DUPLICATE KEY UPDATE but then the fields will have to be listed. But again, having a list of fields doesn't cost anything.
function upd($val) { return sprintf('$s = VALUES(%s)', $val, $val); } $fields = 'fld1, fld2, fldn'; $fld_upd = explode(',', $fields); $fld_upd = array_map('upd', $fld_upd); $fld_upd = implode($fld_upd); $sql = sprintf( 'INSERT INTO data (%s) SELECT %s FROM data_tmp ON DUPLICATE KEY UPDATE %s', $fields, $fields, $fld_upd );