I'm trying to join a second table based on the first 4 characters of a field from the first table but I keep getting "Unknown column 'questions.first4' in 'on clause'" and I'm not sure why:
SELECT questions.id as id, question, answer, correct, SUBSTRING(question,1,4) as first4
FROM questions
LEFT JOIN answers ON answers.correct_answer = questions.first4
WHERE player_name = 'Alpha Squad'
ORDER BY id ASC
(I realize that the tables are structured inefficiently but unfortunately, I have to work with them as-is)
Tables: https://pastebin.com/Gur5ufXa
MySQL: https://pastebin.com/FLgWtQmY
Thanks in advance!