I'm getting the error "Column not found: 1054 Unknown column 'useranswers.userid' in 'on clause'" using the below MySQL code
SELECT COUNT(*) FROM kumianswers
INNER JOIN users on useranswers.userid = users.id
INNER JOIN kumiquestions on useranswers.questionid = kumiquestions.id
WHERE login = '".$username."' and users.level <= 3 and categoryid = 1;
There is a table called 'useranswers' and it does indeed have a column called 'userid' and there is the 'users' table that does have a 'id' field. This is a modification from an old line of code that does work. We had to remake the tables to fit the new system being developed. The old working code was....
SELECT COUNT(*) AS total FROM answers
INNER JOIN users on answers.ans_user = users.user_id
INNER JOIN questions on answers.ans_question = questions.quest_id
WHERE username = '".$username."' and ans_level <= 3 and quest_type = 1;
You're selecting from kumianswers
and joining with users
and kumiquestions
, but you try to compare with a column from useranswers
— a table you're not joining with.