Hi all,
I’m very new to php but I’m using it for my senior project which is a database application for my kids’ school.
I have a Grade field that was given to me as text (e.g., “Third Grade”, “High School”) I would like to change this to a numerical field for sorting. I have been trying to do this using a case statement before inserting the data into the permanent table. It’s in a temp table right now, which I pulled it into from a .csv file.
My question is, is there one query I could use to reassign values to the different grades while simultaneously inserting all the data into the new table?
Basically in the query below, Grade is an int and I want Grd to also be an int. Obviously, the below doesn’t work, but it’s just one of the many versions I’ve tried.
…something like this:
[php]$grdconvert = “SELECT CASE Grade
WHEN ‘Kindergarten’ THEN 0
WHEN ‘Third Grade’ THEN 3
WHEN ‘Eighth Grade’ THEN 8
END AS Grd
FROM MathStandards”;
$insertmath = “INSERT INTO StdLvl1(Grade, Description, SubjectID)
SELECT DISTINCT Grd, Level1Std, ‘1’ FROM MathStandards
ORDER BY Grade”;
[/php]
???