Skip to Content Skip to Menu

[SOLVED] How to update CB-Field based on non-CB tables?

  • ncmed
  • ncmed
  • OFFLINE
  • Posts: 31
  • Thanks: 1
  • Karma: 0
12 years 3 months ago #206375 by ncmed
To make more sense, c_student_id is pulled from user_id originally, so when it is a match in
Code:
WHERE #__quiz_r_student_quiz.c_student_id = #__comprofiler.user_id);
it is updated. The c_passed is the only field option I have to choose from as this is the results given by the quiz, either 0 or 1. I just wanted to add this to the field cb_trainingpass that is already used to show yes or no, if quiz completed and passed.

The ORDER BY looks to be an option if there is a way to select latest date, as there is a date column. Let me look more into that and some of the other things you have mentioned.

Please Log in or Create an account to join the conversation.

  • ncmed
  • ncmed
  • OFFLINE
  • Posts: 31
  • Thanks: 1
  • Karma: 0
12 years 3 months ago #206383 by ncmed
This looks to be working...
Code:
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);
I was able to get the results at stackoverflow here .

Please Log in or Create an account to join the conversation.

Moderators: beatnantkrileon
Powered by Kunena Forum