Question

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?

Was it helpful?

Solution

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'
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top