说我有两张桌子,
Employee
name address phone phone_type
EmployeeContacts
name address phone
因此,我可以这样做:
INSERT INTO Employee name, address, phone VALUES(SELECT name, address, phone from EmployeeContacts where name = "Joe") and phoneType = "mobile"
基本上,插入从一个表中选择的某些值并插入一个额外的值?
如果没有,我该怎么做?
答案 0 :(得分:2)
您想使用insert . . . select
表单:
INSERT INTO Employee(name, address, phone, phonetype)
SELECT name, address, phone, 'mobile'
from EmployeeContacts
where name = 'Joe'