I’m trying to do a select from one table and insert the return values into another table with a common value representing the search parameter using the insert/select function. For simplicities sake instead of…
INSERT INTO tbl_name (a,b) VALUES (1,1,1), (4,5,6);
I want to do something like this….
INSERT INTO tbl_name (a,b) VALUES (1), (4,5,6);
Except where the second column b has several hundred values and ‘a’ is the common value. I’ve tried using SET for ‘a’ but either this can’t be done or I can’t get the syntax correct. The reason I’m doing this is to avoid building up an insert function in PHP. Here is the best I have….
INSERT INTO tbl_name
(a,b)
SET a = '1'
SELECT c
FROM tbl_name2
WHERE `d` LIKE '%word%'
OK I FIGURED IT OUT, already typed all of this, might as well post the answer for everyone.