Reputation: 193
I've the following query:
INSERT INTO
table
(
memberid,
field1,
field2,
field3
)
VALUES
(
:memberid,
(
SELECT
field1,
field2,
field3
FROM
table
WHERE
id = :id
)
)
I'm using PDO prepared statements, but the query doesn't work in this way.
Does anyone know how to combine prepared statements and SELECT variables into one query?
Tnx
Upvotes: 1
Views: 831
Reputation: 24577
Have you considered insert-select?
INSERT INTO mytable (a,b)
SELECT :a, b
FROM myothertable
Upvotes: 3