At 6:53 PM -0700 7/14/07, Steffan A. Cline wrote:
>I was trying to reduce a set of queries and ran into this:
>insert into forums (forum_reply_id, forum_dev_id, forum_subject,
>forum_message) values (0, 1, (select forum_subject from forums where
>forum_id=3 ), "I figured this one needed a reply too.")
>error: You can't specify target table from 'forums' for update in from
>I read somewhere online when they referenced 4.x that said you cannot do
>subqueries in an update. Is this true of 5.x ?
You can do subqueries *unless* you're selecting from the same table
that you're inserting into.
(You're not quite using INSERT INTO ... SELECT syntax, but what
you're doing appears to be effectively equivalent.)
Paul DuBois, MySQL Documentation Team
Madison, Wisconsin, USA
MySQL AB, www.mysql.com