MySQL Forums
Forum List  »  Optimizer & Parser

Re: (How) are subqueries optimized involving the same table?
Posted by: Jakobus Dornier
Date: July 13, 2006 08:20AM

Bob,

thank you for your quick answer.

Yes, but what if I have an INSERT and I'd like to retrieve data from another table:

INSERT INTO
t1
SET
t1.field1 = (SELECT field1 FROM t2 WHERE t2.id = t1.id),
t1.field2 = (SELECT field2 FROM t2 WHERE t2.id = t1.id)
t1.field3 = (SELECT field3 FROM t2 WHERE t2.id = t1.id)


As JOINs are not possible here, would you recommend doing one SELECT first on the application level and passing the values to the INSERT, or can this be done in mysql also? Is the SELECT INTO syntax better than the Subquery Syntax above?

Thanks again.

Options: ReplyQuote


Subject
Views
Written By
Posted
Re: (How) are subqueries optimized involving the same table?
1937
July 13, 2006 08:20AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.