如何根据t_questions对t_answer表中具有正确答案的行进行计数?,
t_user
id (int 10) PK
email (varchar 191)
password (varchar 191)
name (varchar 191)
t_question
id (int 10) PK
question (varchar 191)
choice_a (varchar 191)
choice_b (varchar 191)
choice_c (varchar 191)
choice_d (varchar 191)
correct_answer (enum 'A','B','C','D')
t_answer
id (int 10) PK
id_question (int 10) FK
id_user (int 10) FK
user_answer (enum 'A','B','C','D')
我已经按照以下方式尝试过
$id_user = $request->input('id_user');
$correct_answer = DB::table('t_answer')
->join('t_question', 't_answer.id_question', '=', 't_question.id')
->where('t_answer.id_user', '=', $id_user)
->where('t_answer.user_answer', '=', 't_question.correct_answer')
->count();
但是即使答案正确,结果始终为“ 0”