I'd like to clone all the rows that have YEAR=2020, and assign the GAMECODE field to be the value generated by the php function.
However at the moment that gamecode is only generated once so I am getting a "Duplicate entry" error.
$number = generateGameCode();
$sql = "INSERT INTO games(gamecode, year, rounds)
SELECT '".$number."', year, rounds
FROM games
WHERE year = 2020";
How do I assign a unique newly generated game code for each matching row?
Thanks in advance!
UPDATE
I have to use my php function to generate the value. I cannot just set GAMECODE to auto_increment number in the db.