Click here to Skip to main content
15,909,943 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
my update query is
SQL
UPDATE student_attendance sa,
  (SELECT DISTINCT
     sm.reg_number,
     sm.id,
     sm.cur_academic_id,
     ctm.term_id,
     tmp.Percentage
   FROM tmp_attendancestatus_idcoperator131781 AS tmp,
     students_master sm,
     course_term_master ctm
   WHERE tmp.HallticketNumber = sm.reg_number
       AND ctm.term_id = sm.current_term_id
       AND ctm.semyear = tmp.Year
       AND ctm.semterm = tmp.Semester
       AND TRIM(STATUS) = 'Success'
       AND sm.college_id = 40) AS sd,
  tmp_attendancestatus_idcoperator131781 AS tmpup
SET tmpup.tmpstatus = 1
WHERE sa.student_id = sd.id
    AND sa.academic_id = sd.cur_academic_id
    AND sa.term_id = sd.term_id
    AND sa.attendance_percentage = sd.Percentage
    AND tmpup.HallticketNumber = sd.reg_number



Im using two temporary tables in a update query...but its telling ann error- "cannot reopen the temp table"...give me alternate solution for this query...
Posted
Updated 2-Apr-13 23:10pm
v2

1 solution

Quote:
ERROR 1137: Can't reopen table: 'name'

This error also occurs if you refer to a temporary table multiple times in a stored function under different aliases, even if the references occur in different statements within the function.


Please, read this: http://dev.mysql.com/doc/refman/5.0/en/temporary-table-problems.html[^] and this: http://bugs.mysql.com/bug.php?id=10327[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900