• j-1064772 (5/30/2016)


    Jeff Moden (5/29/2016)


    There's no need to join back to the table to do the DELETE. You can delete from the table by deleting from the CTE.

    [/code]

    Bringing this point up is most relevant. Even though I already knew about it, I keep forgetting about it. While trying to evaluate the proposed solution in my head, I failed to see the join was superfluous.

    Got to admit, it is far from intuitive that acting on a CTE reflects directly on the table it is based on. So easy to use CTE's it is also easy to overlook "side effects" (not a side effect really but if you forget about the implications, then, an apparent side effect).

    Adding the extra joins offers the advantage of stating the intent clearly instead on relying on an "implicit" behaviour. Unless of course performance of such a construct becomes a performance bottleneck, which I doubt.

    Thanks

    I'm right there with you...this seems to be one I always forget about but it would really come in handy at times.


    SELECT quote FROM brain WHERE original = 1
    0 rows returned