Gaetan Gaetan - 4 months ago 9
MySQL Question

How to perform an insert into select

I'm trying to perform an insert into select with mysql.
Is it possible to insert data like this ? or is there an other way to do that ?

A = 17

INSERT INTO TABLE1 (x1, x2, x3)
SELECT (Y,Z) FROM TABLE2
WHERE CONDITION, A


Thanks,

Answer

get it from select statment

INSERT INTO TABLE1 (x1, x2, x3) 
  SELECT (Y,Z,17) FROM TABLE2 
  WHERE CONDITION;
Comments