MySQL Forums
Forum List  »  Optimizer & Parser

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

Hi,

no recursion. I just want to insert a record which is related to another record in another table.

In other words:
I'd just like to insert a new record into a table, which (the new record) is supposed to fetch some fields from a record in another table. (For reasons irrelevant here, this behavior is desired, even though is it not normalized, and foreign keys are not passable here also.)

This could easily achieved via subqueries, but I dont't want to call the same table multiple times.

Sorry, example was misleading. New one:

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

Thanks.



Edited 1 time(s). Last edit at 07/13/2006 08:41AM by Jakobus Dornier.

Options: ReplyQuote


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


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.