假设我有两张桌子,
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"
?
基本上,插入从一个表中选择的某些值,并插入一个额外的值?
如果没有,我怎么做?
最佳答案
您想使用insert . . . select
表单:
INSERT INTO Employee(name, address, phone, phonetype)
SELECT name, address, phone, 'mobile'
from EmployeeContacts
where name = 'Joe'
关于mysql - 从另一个表插入表并获得一个独立的值,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/17800039/