1

有没有办法将所选内容 0 或 1 转换为 no 或 yes 并从表格底部向上搜索?

UPDATE #__comprofiler   
SET cb_trainingpass =   ( SELECT c_passed
FROM #__quiz_r_student_quiz
WHERE #__quiz_r_student_quiz.c_student_id = #__comprofiler.user_id)
WHERE EXISTS
  ( SELECT c_passed
FROM #__quiz_r_student_quiz
WHERE #__quiz_r_student_quiz.c_student_id = #__comprofiler.user_id);

当用户进行测试时,他们会得到 0 = 未通过或 1 = 通过的结果。我将其发送到 cb_trainingpass 字段,并希望它是 yes(通过)或 no。此外,用户多次参加测试,他们的最新结果就是我想要提取的结果,不幸的是,这个查询会拉出顶部的结果或第一个结果,永远不会找到最新的结果。

4

1 回答 1

1

尝试类似的东西

UPDATE #__comprofiler   
SET cb_trainingpass =   ( SELECT if(c_passed=1,'yes','no')
FROM #__quiz_r_student_quiz
WHERE #__quiz_r_student_quiz.c_student_id = #__comprofiler.user_id
order by #__quiz_r_student_quiz.YOURDATEFIELD desc)
WHERE EXISTS
  ( SELECT c_passed
FROM #__quiz_r_student_quiz
WHERE #__quiz_r_student_quiz.c_student_id = #__comprofiler.user_id);
于 2012-07-26T20:21:15.737 回答