Mysql
 sql >> Base de Dados >  >> RDS >> Mysql

SQL UPDATE com subconsulta que faz referência à mesma tabela no MySQL


Alguma referência para você http://dev.mysql.com/doc /refman/5.0/en/update.html
UPDATE user_account student 
INNER JOIN user_account teacher ON
   teacher.user_account_id = student.teacher_id 
   AND teacher.user_type = 'ROLE_TEACHER'
SET student.student_education_facility_id = teacher.education_facility_id