I am trying to insert values into selected columns of table, but only insert the results of a MySQL statement. the select statement works correctly by itself and returns the results.
when combined with the insert statement it is fails with
error incorrect syntax near `dedspgoods`.`case number`.
Can anyone assist me with the correct syntax? my erronous syntax is as below:
insert into despgoods_alldetails
(`case number`, weight, customer, transporttypename)
values
( select despgoods.`case number`
, despgoods.weight
, despgoods.customer
, customers.transporttypename
from despgoods
inner join customers
on despgoods.customer = customers.customer )
If this is the
SELECTthat works:Then try this (notice there is no
VALUESclause if you want to insert the result set of aSELECT: