문제

Say I have two tables,

Employee
name address phone phone_type

EmployeeContacts
name address phone

Hence, can I do something like:

INSERT INTO Employee name, address, phone VALUES(SELECT name, address, phone from EmployeeContacts where name = "Joe") and phoneType = "mobile"

?

Basically, insert certain values selected from one table and INSERT an extra value as well?

If not, how can I do this?

도움이 되었습니까?

해결책

You want to use the insert . . . select form:

INSERT INTO Employee(name, address, phone, phonetype)
    SELECT name, address, phone, 'mobile'
    from EmployeeContacts
    where name = 'Joe'
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top