我有一个名为 college
的数据库和两个名为 student
和 student Personal details
的表,学生表包含stud.Name, dept, address1,address2,address3
。现在,我觉得address1, address2 and address3
字段值移至 student Personal details
(包含相同的字段)表。执行此操作的SQL查询是什么?
答案 0 :(得分:1)
使用insert - select,查询如下,根据您的实际字段进行更正
insert into studentPersonaldetails (address1, address2, address3)
select address1, address2, address3 from student
where student.name = studentPersonaldetails.name
答案 1 :(得分:0)
更新college
。student
,college
。student personal details
组
college
。student
。address1
= college
。student personal details
。address1
,
college
。student
。address2
= college
。student personal details
。address2
,
college
。student
。address3
= college
。student personal details
。address3
哪里
college
。student
。id
= college
。student personal details
。id
;
我认为id
是您为表格设置的主键。