I am a novice at SQL and Php. I am making weekly rota.
I have managed to duplicate a SQL database row in a table using this code below.
INSERT
SELECT
FROM
WHERE
I have modified the above code to include SQL CASE as you can see below, so I can apply a condition to the "weekstart" column. I want to be able to set a condition of, if weekstart date in sql database = $dateone variable then apply $datethree variable or if weekstart date in sql database = $datetwo variable then apply $datefour variable. The modification will be applied to the duplicated row. many thanks.
$dateone = "2026-03-02";
$datetwo = "2026-03-09";
$datethree ="2026-03-16";
$datefour = "2026-03-23";
$sql = "INSERT INTO myrota (weekstart)
SELECT weekstart,
CASE
WHEN weekstart= '$dateone' THEN '$datethree'
WHEN weekstart= '$datetwo' THEN '$datethree'
ELSE 'empty'
END AS weekstart
FROM myrota ";