Alias of scalar subquery Hi,
is there a way I can rewrite this to avoid the double subquery?
UPDATE the_table AS outer_table SET
parent_id = (SELECT id FROM (SELECT * FROM the_table) AS inner_table
WHERE inner_table.number = outer_table.parent_number),
changed_flag = 1
WHERE outer_table.parent_id != (SELECT id FROM (SELECT * FROM
the_table) AS inner_table WHERE inner_table.number =
outer_table.parent_number)
Note that the two suqueries are absolutely identical.
BTW: Certainly this is a problem of clarity but is it also a problem
of performance or is the subquery cached?
Regards,
André |