Php 通过从两个表中获取值来更新表1
我正在使用mysql数据库 要通过从两个或多个表中获取值,在特定条件下更新表1吗 范例Php 通过从两个表中获取值来更新表1,php,mysql,Php,Mysql,我正在使用mysql数据库 要通过从两个或多个表中获取值,在特定条件下更新表1吗 范例 table1 id | stdId | trId | std_name | std_lname |std_edu_college |std_edu_cource 01 | 1256 | 2341 | student table stdId | name | lname
table1
id | stdId | trId | std_name | std_lname |std_edu_college |std_edu_cource
01 | 1256 | 2341 |
student table
stdId | name | lname
1256 |Mallu |Malage
student_education table
stdId | college | cource
1256 | BEC | Engineering
想用学生和学生大学教育数据更新表1吗
像这样,我在表1中有大约100列具有不同的列名
我知道通过加入并设置每个受尊重的列来使用更新表1,但我想像循环或简易方式一样进行更新,所以有人请帮助我试试这一个
UPDATE `table1` as tbl
inner join student as std on tbl.stdId=std.stdId
inner join student_education as stdEd on tbl.stdId=stdEd.stdId
SET tbl.`std_name`=std.name
SET tbl.`std_lname`=std.lname
SET tbl.`std_edu_college`=stdEd.college
SET tbl.`std_edu_cource`=stdEd.cource
WHERE tbl.stdId=1256
我想它会帮助你解决你的问题。可能的重复:可能的重复