@array1 = [ 1 ,2 , 3]; @array2 = [4, 5, 6]; #### foreach $user(@array1){ $sth -> $dbh ->perpare("INSERT INTO `trial` (User) VALUES ('$user')"); $sth->execute(); foreach $time(@array2){ $sth -> $dbh ->perpare("INSERT INTO `trial` (Time) VALUES ('$time')"); $sth->execute(); #### User Time 1 NULL 2 NULL 3 NULL NULL 4 NULL 5 NULL 6 #### User Time 1 4 2 5 3 6