I am getting this error:
#1054 - Unknown column 'examinationresults.userid' in 'on clause'
I've seen other posts on this but I can't seem to figure it out. I don't think I'm referring to anything out of order...
SELECT examinationresults.id AS id, examinationresults.examid AS examid,
examination.tag AS examtag, examination.title AS examtitle, examinationresults.revision AS revision,
examination.medicalspecialtyid AS medicalspecialtyid, medicalspecialties.title AS medicalspecialtytitle,
examination.institutionid AS institutionid, institutions.title AS institutiontitle,
examinationresults.grade AS grade, examinationresults.points AS points, examinationresults.pointsof AS pointsof,
examinationresults.datebegan AS datebegan, examinationresults.datefinished AS datefinished,
examinationresults.totaltime AS totaltime, examinationresults.finished AS finished, examinationresults.graded AS graded,
users.username AS username, users.firstname AS firstname, users.middlename AS middlename, users.lastname AS lastname
FROM examinationresults, examination
INNER JOIN medicalspecialties
ON examination.medicalspecialtyid=medicalspecialties.id
INNER JOIN institutions
ON examination.institutionid=institutions.id
INNER JOIN users
ON examinationresults.userid=users.id
WHERE examination.examid=examinationresults.examid AND examination.revision=examinationresults.revision AND examinationresults.userid='1'
ORDER BY examinationresults.datefinished ASC;
You have
FROM examinationresults, examination
INNER JOIN medicalspecialties /*....*/
Don't mix ANSI 89 and ANSI 92 join styles.
Use the INNER JOIN
syntax for examinationresults
and examination
too.
FROM examinationresults
INNER JOIN examination
ON examination.examid = examinationresults.examid
AND examination.revision = examinationresults.revision
INNER JOIN medicalspecialties
ON examination.medicalspecialtyid = medicalspecialties.id
INNER JOIN institutions
ON examination.institutionid = institutions.id
INNER JOIN users
ON examinationresults.userid = users.id
WHERE examinationresults.userid = '1'
You forget to use the INNER JOIN syntax for examinationresults
and examination
.Try this:
SELECT examinationresults.id AS id, examinationresults.examid AS examid,
examination.tag AS examtag, examination.title AS examtitle, examinationresults.revision AS revision,
examination.medicalspecialtyid AS medicalspecialtyid, medicalspecialties.title AS medicalspecialtytitle,
examination.institutionid AS institutionid, institutions.title AS institutiontitle,
examinationresults.grade AS grade, examinationresults.points AS points, examinationresults.pointsof AS pointsof,
examinationresults.datebegan AS datebegan, examinationresults.datefinished AS datefinished,
examinationresults.totaltime AS totaltime, examinationresults.finished AS finished, examinationresults.graded AS graded,
users.username AS username, users.firstname AS firstname, users.middlename AS middlename, users.lastname AS lastname
FROM examinationresults
INNER JOIN examination
ON examination.examid = examinationresults.examid
AND examination.revision = examinationresults.revision
INNER JOIN medicalspecialties
ON examination.medicalspecialtyid = medicalspecialties.id
INNER JOIN institutions
ON examination.institutionid = institutions.id
INNER JOIN users
ON examinationresults.userid = users.id
WHERE examinationresults.userid = '1'
On a side note:
You may check
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With